From 8d723fdf1151366998bbdc32960f09e047ab4923 Mon Sep 17 00:00:00 2001 From: awkj Date: Thu, 10 Jan 2019 18:13:35 +0800 Subject: [PATCH] add notify accept signal --- examples/graceful-shutdown/graceful-shutdown/server.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/graceful-shutdown/graceful-shutdown/server.go b/examples/graceful-shutdown/graceful-shutdown/server.go index af4f2146..a75f1646 100644 --- a/examples/graceful-shutdown/graceful-shutdown/server.go +++ b/examples/graceful-shutdown/graceful-shutdown/server.go @@ -35,7 +35,10 @@ func main() { // Wait for interrupt signal to gracefully shutdown the server with // a timeout of 5 seconds. quit := make(chan os.Signal) - signal.Notify(quit, os.Interrupt) + // kill (no param) default send syscanll.SIGTERM + // kill -2 is syscall.SIGINT + // kill -9 is syscall. SIGKILL but can"t be catch + signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM) <-quit log.Println("Shutdown Server ...")