1
0
Fork 0

Cause a proper server shutdown if a list reload fail by defering it.

This commit is contained in:
Alexander Andreev 2024-01-13 04:41:46 +04:00
parent 99d53b31a0
commit 64b5966b48
Signed by: Arav
GPG Key ID: D22A817D95815393
1 changed files with 7 additions and 5 deletions

12
main.go
View File

@ -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 {