Merge pull request #3109 from nicollet/main

Fixup: make signal handlers a bit simpler.
This commit is contained in:
Simon Pasquier 2023-01-06 15:36:37 +01:00 committed by GitHub
commit ecb66f76b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 19 deletions

View File

@ -555,14 +555,11 @@ func run() int {
var ( var (
hup = make(chan os.Signal, 1) hup = make(chan os.Signal, 1)
hupReady = make(chan bool)
term = make(chan os.Signal, 1) term = make(chan os.Signal, 1)
) )
signal.Notify(hup, syscall.SIGHUP) signal.Notify(hup, syscall.SIGHUP)
signal.Notify(term, os.Interrupt, syscall.SIGTERM) signal.Notify(term, os.Interrupt, syscall.SIGTERM)
go func() {
<-hupReady
for { for {
select { select {
case <-hup: case <-hup:
@ -570,15 +567,6 @@ func run() int {
_ = configCoordinator.Reload() _ = configCoordinator.Reload()
case errc := <-webReload: case errc := <-webReload:
errc <- configCoordinator.Reload() errc <- configCoordinator.Reload()
}
}
}()
// Wait for reload or termination signals.
close(hupReady) // Unblock SIGHUP handler.
for {
select {
case <-term: case <-term:
level.Info(logger).Log("msg", "Received SIGTERM, exiting gracefully...") level.Info(logger).Log("msg", "Received SIGTERM, exiting gracefully...")
return 0 return 0