diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go index cdb85f13b7..a72d26b359 100644 --- a/cmd/prometheus/main.go +++ b/cmd/prometheus/main.go @@ -78,6 +78,11 @@ func Main() int { reloadables []Reloadable ) + // Make sure that sighup handler is registered with a redirect to the channel before the potentially + // long and synchronous tsdb init. + hup := make(chan os.Signal) + hupReady := make(chan bool) + signal.Notify(hup, syscall.SIGHUP) localStorage, err := tsdb.Open(cfg.localStoragePath, prometheus.DefaultRegisterer, &cfg.tsdb) if err != nil { log.Errorf("Opening storage failed: %s", err) @@ -136,9 +141,6 @@ func Main() int { // Wait for reload or termination signals. Start the handler for SIGHUP as // early as possible, but ignore it until we are ready to handle reloading // our config. - hup := make(chan os.Signal) - hupReady := make(chan bool) - signal.Notify(hup, syscall.SIGHUP) go func() { <-hupReady for {