Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: shutdown gracefully on both SIGINT and SIGTERM (#167)

satorub2fb5689ca9b
diff --git a/bin/server/cmd/root.go b/bin/server/cmd/root.go
index 2f67990e32..329740e15a 100644
--- a/bin/server/cmd/root.go
+++ b/bin/server/cmd/root.go
@@ -8,6 +8,7 @@ import (
"os/signal"
"path/filepath"
"strings"
+ "syscall"
"time"
"github.com/bytebase/bytebase/api"
@@ -190,7 +191,10 @@ func start() {
// Setup signal handlers.
ctx, cancel := context.WithCancel(context.Background())
c := make(chan os.Signal, 1)
- signal.Notify(c, os.Interrupt)
+ // Trigger graceful shutdown on SIGINT or SIGTERM.
+ // The default signal sent by the `kill` command is SIGTERM,
+ // which is taken as the graceful shutdown signal for many systems, eg., Kubernetes, Gunicorn.
+ signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
m.l.Info("SIGINT received.")