From 271748ee09756cb9ade06e4d2e64414524540010 Mon Sep 17 00:00:00 2001 From: Stan Xing Date: Sat, 21 Mar 2020 19:05:07 +0800 Subject: [PATCH] fix: support capturing SIGTERM signal to shutdown gracefully (#82) --- cmd/server.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/server.go b/cmd/server.go index 887fb93..bc638d8 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -18,6 +18,7 @@ import ( "net/http" "os" "os/signal" + "syscall" "time" "github.com/hipages/php-fpm_exporter/phpfpm" @@ -93,9 +94,9 @@ to quickly create a Cobra application.`, }() c := make(chan os.Signal, 1) - // We'll accept graceful shutdowns when quit via SIGINT (Ctrl+C) - // SIGKILL, SIGQUIT or SIGTERM (Ctrl+/) will not be caught. - signal.Notify(c, os.Interrupt) + // We'll accept graceful shutdowns when quit via SIGINT (Ctrl+C) or SIGTERM + // SIGKILL, SIGQUIT will not be caught. + signal.Notify(c, os.Interrupt, syscall.SIGTERM) // Block until we receive our signal. <-c