Merge pull request #2700 from improbable-io/bugfix/2699-p2-sighup

Fixup sighup for P2 TSDB init #2699
pull/2710/head
Fabian Reinartz 2017-05-10 10:14:02 +02:00 committed by GitHub
commit 373bec3784
1 changed files with 5 additions and 3 deletions

View File

@ -78,6 +78,11 @@ func Main() int {
reloadables []Reloadable 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) localStorage, err := tsdb.Open(cfg.localStoragePath, prometheus.DefaultRegisterer, &cfg.tsdb)
if err != nil { if err != nil {
log.Errorf("Opening storage failed: %s", err) 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 // 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 // early as possible, but ignore it until we are ready to handle reloading
// our config. // our config.
hup := make(chan os.Signal)
hupReady := make(chan bool)
signal.Notify(hup, syscall.SIGHUP)
go func() { go func() {
<-hupReady <-hupReady
for { for {