Skip to content

Commit

Permalink
add SIGTERM/SIGINT handler for gracefull shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
msaf1980 committed Sep 14, 2021
1 parent aef60a0 commit 5691753
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion carbon-clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func main() {

go func() {
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGUSR1, syscall.SIGUSR2, syscall.SIGHUP)
signal.Notify(c, syscall.SIGUSR1, syscall.SIGUSR2, syscall.SIGHUP, syscall.SIGTERM, syscall.SIGINT)

for {
s := <-c
Expand All @@ -149,6 +149,9 @@ func main() {
mainLogger.Info("SIGUSR2 received. Ignoring")
case syscall.SIGHUP:
mainLogger.Info("SIGHUP received. Ignoring")
case syscall.SIGTERM, syscall.SIGINT:
mainLogger.Info("shutting down")
app.Stop()
}
}
}()
Expand Down

0 comments on commit 5691753

Please sign in to comment.