Skip to content

Commit

Permalink
Add graceful shutdown.
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghaowei0107 committed Jan 5, 2024
1 parent 769064a commit d7c7511
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,7 @@ func main() {

s := make(chan os.Signal, 1)
signal.Notify(s, syscall.SIGINT, syscall.SIGTERM)
go func() {
select {
case _s := <-s:
log.Infof("Receive exit signal, bye! signal: %s", _s.String())
os.Exit(0)
}
}()
_sig := <-s
log.Infof("Receive exit signal, bye! Signal: %s", _sig.String())
os.Exit(0)
}

0 comments on commit d7c7511

Please sign in to comment.