mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-19 07:38:57 +08:00
Fix Shutdown() sample
see: https://github.com/gin-gonic/examples/blob/master/graceful-shutdown/graceful-shutdown/server.go#L46-L51
This commit is contained in:
parent
2e5a7196cc
commit
460cc93311
@ -1759,7 +1759,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 syscall.SIGTERM
|
||||
// kill -2 is syscall.SIGINT
|
||||
// kill -9 is syscall.SIGKILL but can't be catch, so don't need add it
|
||||
@ -1772,11 +1772,7 @@ func main() {
|
||||
if err := srv.Shutdown(ctx); err != nil {
|
||||
log.Fatal("Server Shutdown: ", err)
|
||||
}
|
||||
// catching ctx.Done(). timeout of 5 seconds.
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
log.Println("timeout of 5 seconds.")
|
||||
}
|
||||
|
||||
log.Println("Server exiting")
|
||||
}
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user