Skip to content

Commit

Permalink
Update: examples/graceful-shutdown/graceful-shutdown/server.go (gin-g…
Browse files Browse the repository at this point in the history
…onic#9)

Because staticcheck pointed out the following:
- SA1017 https://staticcheck.io/docs/checks#SA1017
- S1000 https://staticcheck.io/docs/checks#S1000
  • Loading branch information
nekottyo authored and thinkerou committed Apr 6, 2019
1 parent 386c36b commit 121bb3b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions graceful-shutdown/graceful-shutdown/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func main() {

// Wait for interrupt signal to gracefully shutdown the server with
// a timeout of 5 seconds.
quit := make(chan os.Signal)
quit := make(chan os.Signal, 1)
// kill (no param) default send syscanll.SIGTERM
// kill -2 is syscall.SIGINT
// kill -9 is syscall. SIGKILL but can"t be catch, so don't need add it
Expand All @@ -49,9 +49,8 @@ func main() {
log.Fatal("Server Shutdown:", err)
}
// catching ctx.Done(). timeout of 5 seconds.
select {
case <-ctx.Done():
log.Println("timeout of 5 seconds.")
}
<-ctx.Done()
log.Println("timeout of 5 seconds.")

log.Println("Server exiting")
}

0 comments on commit 121bb3b

Please sign in to comment.