Skip to content

Commit

Permalink
chore: handle SIGTERM
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Jan 2, 2025
1 parent 4be7147 commit 3712291
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions shutdown/shutdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"os/signal"
"sync"
"syscall"
"time"

"github.com/flanksource/commons/logger"
Expand Down Expand Up @@ -79,9 +80,9 @@ func AddHookWithPriority(label string, priority int, fn shutdownHook) {
func WaitForSignal() {
go func() {
quit := make(chan os.Signal, 1)
signal.Notify(quit, os.Interrupt)
<-quit
logger.Infof("Caught Ctrl+C")
signal.Notify(quit, os.Interrupt, syscall.SIGTERM)
sig := <-quit
logger.Infof("caught signal: %s", sig)
// call shutdown hooks explicitly, post-run cleanup hooks will be a no-op
Shutdown()
}()
Expand Down

0 comments on commit 3712291

Please sign in to comment.