mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-10 15:44:05 -08:00
Merge pull request #798 from miekg/hup-signal-handing
Start HUP signal handler earlier
This commit is contained in:
commit
6247bd5a5a
21
main.go
21
main.go
|
@ -247,6 +247,19 @@ func (p *prometheus) reloadConfig() bool {
|
|||
// down. The method installs an interrupt handler, allowing to trigger a
|
||||
// shutdown by sending SIGTERM to the process.
|
||||
func (p *prometheus) Serve() {
|
||||
// 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 range hup {
|
||||
p.reloadConfig()
|
||||
}
|
||||
}()
|
||||
|
||||
// Start all components.
|
||||
if err := p.storage.Start(); err != nil {
|
||||
log.Errorln("Error opening memory series storage:", err)
|
||||
|
@ -280,13 +293,7 @@ func (p *prometheus) Serve() {
|
|||
go p.webService.Run()
|
||||
|
||||
// Wait for reload or termination signals.
|
||||
hup := make(chan os.Signal)
|
||||
signal.Notify(hup, syscall.SIGHUP)
|
||||
go func() {
|
||||
for range hup {
|
||||
p.reloadConfig()
|
||||
}
|
||||
}()
|
||||
close(hupReady) // Unblock SIGHUP handler.
|
||||
|
||||
term := make(chan os.Signal)
|
||||
signal.Notify(term, os.Interrupt, syscall.SIGTERM)
|
||||
|
|
Loading…
Reference in a new issue