X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f1b67a590f30b5f8824b14f7b49520106a13bb29..a88aa282a8da52589053244f4ef41283d51f629a:/lib/boot/supervisor.go diff --git a/lib/boot/supervisor.go b/lib/boot/supervisor.go index 52cd0b1616..ddc17953d2 100644 --- a/lib/boot/supervisor.go +++ b/lib/boot/supervisor.go @@ -113,28 +113,24 @@ func (super *Supervisor) Start(ctx context.Context) { super.done = make(chan struct{}) sigch := make(chan os.Signal) - signal.Notify(sigch, syscall.SIGINT, syscall.SIGTERM) - defer signal.Stop(sigch) + signal.Notify(sigch, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP) go func() { - for sig := range sigch { - super.logger.WithField("signal", sig).Info("caught signal") - if super.err == nil { - super.err = fmt.Errorf("caught signal %s", sig) - } - super.cancel() - } - }() - - hupch := make(chan os.Signal) - signal.Notify(hupch, syscall.SIGHUP) - defer signal.Stop(hupch) - go func() { - for sig := range hupch { - super.logger.WithField("signal", sig).Info("caught signal") - if super.err == nil { - super.err = errNeedConfigReload + defer signal.Stop(sigch) + for { + select { + case <-ctx.Done(): + return + case sig := <-sigch: + super.logger.WithField("signal", sig).Info("caught signal") + if super.err == nil { + if sig == syscall.SIGHUP { + super.err = errNeedConfigReload + } else { + super.err = fmt.Errorf("caught signal %s", sig) + } + } + super.cancel() } - super.cancel() } }() @@ -251,13 +247,9 @@ func (super *Supervisor) runCluster() error { } if super.ListenHost == "" { - if urlhost := super.cluster.Services.Controller.ExternalURL.Host; urlhost != "" { - if h, _, _ := net.SplitHostPort(urlhost); h != "" { - super.ListenHost = h - } else { - super.ListenHost = urlhost - } - } else { + u := url.URL(super.cluster.Services.Controller.ExternalURL) + super.ListenHost = u.Hostname() + if super.ListenHost == "" { super.ListenHost = "0.0.0.0" } }