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)
|
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)
|
syssignal := make(chan os.Signal, 1)
|
||||||
signal.Notify(syssignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
|
signal.Notify(syssignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
|
||||||
@ -80,11 +86,7 @@ func main() {
|
|||||||
case os.Interrupt:
|
case os.Interrupt:
|
||||||
fallthrough
|
fallthrough
|
||||||
case syscall.SIGINT | syscall.SIGTERM:
|
case syscall.SIGINT | syscall.SIGTERM:
|
||||||
srv.SetKeepAlivesEnabled(false)
|
return
|
||||||
if err := srv.Shutdown(context.Background()); err != nil {
|
|
||||||
log.Fatalf("%s\n", err)
|
|
||||||
}
|
|
||||||
os.Exit(0)
|
|
||||||
case syscall.SIGHUP:
|
case syscall.SIGHUP:
|
||||||
newconf, err := LoadConfiguration(*configPath)
|
newconf, err := LoadConfiguration(*configPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user