Skip to content

Commit

Permalink
Fix graceful restart or stop example code
Browse files Browse the repository at this point in the history
  • Loading branch information
luncrzs authored Dec 14, 2024
1 parent 4371021 commit b92c749
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion content/en/docs/examples/graceful-restart-or-stop.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ func main() {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if err := srv.Shutdown(ctx); err != nil {
log.Fatal("Server Shutdown:", err)
log.Println("Server Shutdown:", err)
}
// catching ctx.Done(). timeout of 5 seconds.
select {
case <-ctx.Done():
log.Println("timeout of 5 seconds.")
default:
break
}
log.Println("Server exiting")
}
Expand Down

0 comments on commit b92c749

Please sign in to comment.