diff --git a/server/server.go b/server/server.go index 9461f3f451d..257ccea8821 100644 --- a/server/server.go +++ b/server/server.go @@ -27,6 +27,7 @@ func Listen(cfg *config.Configuration, handler http.Handler, adminHandler http.H stopAdmin := make(chan os.Signal) stopMain := make(chan os.Signal) stopPrometheus := make(chan os.Signal) + stopChannels := []chan<- os.Signal{stopMain} done := make(chan struct{}) if cfg.UnixSocketEnable && len(cfg.UnixSocketName) > 0 { // start the unix_socket server if config enable-it. @@ -54,6 +55,7 @@ func Listen(cfg *config.Configuration, handler http.Handler, adminHandler http.H } if cfg.Admin.Enabled { + stopChannels = append(stopChannels, stopAdmin) adminServer := newAdminServer(cfg, adminHandler) go shutdownAfterSignals(adminServer, stopAdmin, done) @@ -70,6 +72,7 @@ func Listen(cfg *config.Configuration, handler http.Handler, adminHandler http.H prometheusListener net.Listener prometheusServer = newPrometheusServer(cfg, metrics) ) + stopChannels = append(stopChannels, stopPrometheus) go shutdownAfterSignals(prometheusServer, stopPrometheus, done) if prometheusListener, err = newTCPListener(prometheusServer.Addr, nil); err != nil { glog.Errorf("Error listening for TCP connections on %s: %v for prometheus server", prometheusServer.Addr, err) @@ -77,11 +80,10 @@ func Listen(cfg *config.Configuration, handler http.Handler, adminHandler http.H } go runServer(prometheusServer, "Prometheus", prometheusListener) - wait(stopSignals, done, stopMain, stopAdmin, stopPrometheus) - } else { - wait(stopSignals, done, stopMain, stopAdmin) } + wait(stopSignals, done, stopChannels...) + return }