Skip to content

Commit c96e2e1

Browse files
committed
Use buffered channel for graceful shutdown
According to https://golang.org/pkg/os/signal/#example_Notify buffered channel should be used to avoid missing signal.
1 parent 4a95c8f commit c96e2e1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cookbook/graceful-shutdown/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func main() {
2929

3030
// Wait for interrupt signal to gracefully shutdown the server with
3131
// a timeout of 10 seconds.
32-
quit := make(chan os.Signal)
32+
quit := make(chan os.Signal, 1)
3333
signal.Notify(quit, os.Interrupt)
3434
<-quit
3535
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)

0 commit comments

Comments
 (0)