Cause a proper server shutdown if a list reload fail by defering it.
This commit is contained in:
parent
99d53b31a0
commit
64b5966b48
12
main.go
12
main.go
@ -71,6 +71,12 @@ func main() {
|
||||
log.Fatalf("ListenAndServe: %s\n", err)
|
||||
}
|
||||
}()
|
||||
defer func() {
|
||||
srv.SetKeepAlivesEnabled(false)
|
||||
if err := srv.Shutdown(context.Background()); err != nil {
|
||||
log.Fatalf("%s\n", err)
|
||||
}
|
||||
}()
|
||||
|
||||
syssignal := make(chan os.Signal, 1)
|
||||
signal.Notify(syssignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
|
||||
@ -80,11 +86,7 @@ func main() {
|
||||
case os.Interrupt:
|
||||
fallthrough
|
||||
case syscall.SIGINT | syscall.SIGTERM:
|
||||
srv.SetKeepAlivesEnabled(false)
|
||||
if err := srv.Shutdown(context.Background()); err != nil {
|
||||
log.Fatalf("%s\n", err)
|
||||
}
|
||||
os.Exit(0)
|
||||
return
|
||||
case syscall.SIGHUP:
|
||||
newconf, err := LoadConfiguration(*configPath)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user