mirror of
https://github.com/prometheus/alertmanager
synced 2024-12-28 17:12:13 +00:00
Merge pull request #3109 from nicollet/main
Fixup: make signal handlers a bit simpler.
This commit is contained in:
commit
ecb66f76b0
@ -554,31 +554,19 @@ func run() int {
|
||||
}()
|
||||
|
||||
var (
|
||||
hup = make(chan os.Signal, 1)
|
||||
hupReady = make(chan bool)
|
||||
term = make(chan os.Signal, 1)
|
||||
hup = make(chan os.Signal, 1)
|
||||
term = make(chan os.Signal, 1)
|
||||
)
|
||||
signal.Notify(hup, syscall.SIGHUP)
|
||||
signal.Notify(term, os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
go func() {
|
||||
<-hupReady
|
||||
for {
|
||||
select {
|
||||
case <-hup:
|
||||
// ignore error, already logged in `reload()`
|
||||
_ = configCoordinator.Reload()
|
||||
case errc := <-webReload:
|
||||
errc <- configCoordinator.Reload()
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
// Wait for reload or termination signals.
|
||||
close(hupReady) // Unblock SIGHUP handler.
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-hup:
|
||||
// ignore error, already logged in `reload()`
|
||||
_ = configCoordinator.Reload()
|
||||
case errc := <-webReload:
|
||||
errc <- configCoordinator.Reload()
|
||||
case <-term:
|
||||
level.Info(logger).Log("msg", "Received SIGTERM, exiting gracefully...")
|
||||
return 0
|
||||
|
Loading…
Reference in New Issue
Block a user