Skip to content

Commit

Permalink
cmd: Support double signal handling
Browse files Browse the repository at this point in the history
Signed-off-by: Kosy Anyanwu <kosy@kinvolk.io>
  • Loading branch information
kosyfrances committed May 23, 2018
1 parent 8135e9d commit 9ae26eb
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions cmd/habitat-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 9ae26eb

Please sign in to comment.