forked from mirror/gin
Update: examples/graceful-shutdown/server.go (#1530)
* Update server.go It's necessary that catching ctx.Done() * Update server.go * Update server.go * Update README.md * Update README.md
This commit is contained in:
parent
fece76d93f
commit
90587c7787
|
@ -1673,6 +1673,11 @@ func main() {
|
||||||
if err := srv.Shutdown(ctx); err != nil {
|
if err := srv.Shutdown(ctx); err != nil {
|
||||||
log.Fatal("Server Shutdown:", err)
|
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")
|
log.Println("Server exiting")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -48,5 +48,10 @@ func main() {
|
||||||
if err := srv.Shutdown(ctx); err != nil {
|
if err := srv.Shutdown(ctx); err != nil {
|
||||||
log.Fatal("Server Shutdown:", err)
|
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")
|
log.Println("Server exiting")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue