diff --git a/cmd/habitat-operator/main.go b/cmd/habitat-operator/main.go index c22f206f..448afd92 100644 --- a/cmd/habitat-operator/main.go +++ b/cmd/habitat-operator/main.go @@ -112,12 +112,17 @@ func run() int { // Relay these signals to the `term` channel. signal.Notify(term, syscall.SIGINT, syscall.SIGTERM) - select { - case <-term: + go func() { + <-term level.Info(logger).Log("msg", "received SIGTERM, exiting gracefully...") - case <-ctx.Done(): - level.Info(logger).Log("msg", "context channel closed, exiting") - } + cancelFunc() + + <-term + os.Exit(1) + }() + + <-ctx.Done() + level.Info(logger).Log("msg", "context channel closed, exiting") return 0 }