mirror of
https://github.com/prometheus/prometheus
synced 2024-12-26 16:43:21 +00:00
Start HUP signal handler earlier
When prometheus starts up and is recovering its state it will not handle SIGHUPs. If it receives those during this phase it will exit. The change here makes prometheus ignore SIGHUPs until it is ready to handle them. Note this is only done for SIGHUP because that signal is used for trigger a config reload and a such something could already be sending these signals as part of a config update.
This commit is contained in:
parent
0542733964
commit
d8651302fc
22
main.go
22
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)
|
||||
block := make(chan bool)
|
||||
signal.Notify(hup, syscall.SIGHUP)
|
||||
go func() {
|
||||
<-block
|
||||
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,8 @@ 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()
|
||||
}
|
||||
}()
|
||||
block <- true // Unblock SIGHUP handler.
|
||||
close(block)
|
||||
|
||||
term := make(chan os.Signal)
|
||||
signal.Notify(term, os.Interrupt, syscall.SIGTERM)
|
||||
|
Loading…
Reference in New Issue
Block a user