Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add graceful shutdown on SIGTERM #672

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmd/tile38-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -433,7 +434,7 @@ Developer Options:
case s == syscall.SIGQUIT:
os.Exit(3)
case s == syscall.SIGTERM:
os.Exit(0xf)
shutdown <- true
}
}
}()
Expand Down Expand Up @@ -481,6 +482,7 @@ Developer Options:
AppendOnly: appendOnly,
AppendFileName: appendFileName,
QueueFileName: queueFileName,
Shutdown: shutdown,
}
if err := server.Serve(opts); err != nil {
log.Fatal(err)
Expand Down