examples/server: Cancel context
This commit is contained in:
parent
991b18d526
commit
19bfca1cc3
@ -48,7 +48,8 @@ func main() {
|
||||
case <-c:
|
||||
// Shutdown the server
|
||||
log.Println("Shutting down...")
|
||||
ctx, _ := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
err := server.Shutdown(ctx)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
Loading…
Reference in New Issue
Block a user