examples/server: Cancel context

This commit is contained in:
Adnan Maolood 2021-02-24 10:27:28 -05:00
parent 991b18d526
commit 19bfca1cc3

View File

@ -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)