From eddc371201d5eab22acab95848998c0f9d97e37f Mon Sep 17 00:00:00 2001 From: Dilnawaz-khan-ops Date: Wed, 11 Jun 2025 16:32:51 +0530 Subject: [PATCH] Reusing the existing fucntion to implement graceful shutdown logic (#33) --- share/cos/common.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/share/cos/common.go b/share/cos/common.go index 9098044d..48c2b6e5 100644 --- a/share/cos/common.go +++ b/share/cos/common.go @@ -5,6 +5,8 @@ import ( "os" "os/signal" "time" + "syscall" + "log" ) //InterruptContext returns a context which is @@ -13,9 +15,11 @@ func InterruptContext() context.Context { ctx, cancel := context.WithCancel(context.Background()) go func() { sig := make(chan os.Signal, 1) - signal.Notify(sig, os.Interrupt) //windows compatible? - <-sig + signal.Notify(sig, os.Interrupt, syscall.SIGTERM) //windows compatible? + s := <-sig + log.Printf("Graceful shutdown signal received: %s", s) signal.Stop(sig) + log.Println("Graceful shutdown complete.") cancel() }() return ctx