From aa1060a60f03cf2ba083af024419b43f0e02ee95 Mon Sep 17 00:00:00 2001 From: Dmitrii Zganiaiko Date: Thu, 23 Feb 2023 12:01:51 +0200 Subject: [PATCH] Add graceful shutdown on SIGTERM --- cmd/tile38-server/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/tile38-server/main.go b/cmd/tile38-server/main.go index 58a1fd54..7baf7128 100644 --- a/cmd/tile38-server/main.go +++ b/cmd/tile38-server/main.go @@ -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)