Merge pull request #672 from dmitri-zganiaiko/graceful-shutdown-on-sigterm

Add graceful shutdown on SIGTERM
This commit is contained in:
Josh Baker 2023-05-06 06:20:33 -07:00 committed by GitHub
commit 65f0370438
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -413,6 +413,7 @@ Developer Options:
}
c := make(chan os.Signal, 1)
shutdown := make (chan bool, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
go func() {
@ -433,7 +434,7 @@ Developer Options:
case s == syscall.SIGQUIT:
os.Exit(3)
case s == syscall.SIGTERM:
os.Exit(0xf)
shutdown <- true
}
}
}()
@ -481,6 +482,7 @@ Developer Options:
AppendOnly: appendOnly,
AppendFileName: appendFileName,
QueueFileName: queueFileName,
Shutdown: shutdown,
}
if err := server.Serve(opts); err != nil {
log.Fatal(err)