fix: graceful shutdown should use buffered signal

The channel used with signal.Notify should be buffered.
ref: https://pkg.go.dev/os/signal#Notify
This commit is contained in:
rickwang7712 2022-07-08 15:20:52 +08:00 committed by GitHub
parent b57163a0e4
commit 40a1d275c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1841,7 +1841,7 @@ func main() {
// Wait for interrupt signal to gracefully shutdown the server with // Wait for interrupt signal to gracefully shutdown the server with
// a timeout of 5 seconds. // a timeout of 5 seconds.
quit := make(chan os.Signal) quit := make(chan os.Signal, 1)
// kill (no param) default send syscall.SIGTERM // kill (no param) default send syscall.SIGTERM
// kill -2 is syscall.SIGINT // kill -2 is syscall.SIGINT
// kill -9 is syscall.SIGKILL but can't be caught, so don't need to add it // kill -9 is syscall.SIGKILL but can't be caught, so don't need to add it