Skip to content

Commit 271748e

Browse files
author
Stan Xing
authored
fix: support capturing SIGTERM signal to shutdown gracefully (#82)
1 parent 2ed0404 commit 271748e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cmd/server.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"net/http"
1919
"os"
2020
"os/signal"
21+
"syscall"
2122
"time"
2223

2324
"github.com/hipages/php-fpm_exporter/phpfpm"
@@ -93,9 +94,9 @@ to quickly create a Cobra application.`,
9394
}()
9495

9596
c := make(chan os.Signal, 1)
96-
// We'll accept graceful shutdowns when quit via SIGINT (Ctrl+C)
97-
// SIGKILL, SIGQUIT or SIGTERM (Ctrl+/) will not be caught.
98-
signal.Notify(c, os.Interrupt)
97+
// We'll accept graceful shutdowns when quit via SIGINT (Ctrl+C) or SIGTERM
98+
// SIGKILL, SIGQUIT will not be caught.
99+
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
99100

100101
// Block until we receive our signal.
101102
<-c

0 commit comments

Comments
 (0)