We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 3b9fa82 + 623577e commit ec9f6c5Copy full SHA for ec9f6c5
cookbook/graceful-shutdown/server.go
@@ -27,9 +27,9 @@ func main() {
27
}
28
}()
29
30
- // Wait for interrupt signal to gracefully shutdown the server with
31
- // a timeout of 10 seconds.
32
- quit := make(chan os.Signal)
+ // Wait for interrupt signal to gracefully shutdown the server with a timeout of 10 seconds.
+ // Use a buffered channel to avoid missing signals as recommended for signal.Notify
+ quit := make(chan os.Signal, 1)
33
signal.Notify(quit, os.Interrupt)
34
<-quit
35
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
0 commit comments