Skip to content

Commit

Permalink
fix: support capturing SIGTERM signal to shutdown gracefully (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stan Xing authored Mar 21, 2020
1 parent 2ed0404 commit 271748e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"net/http"
"os"
"os/signal"
"syscall"
"time"

"github.com/hipages/php-fpm_exporter/phpfpm"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 271748e

Please sign in to comment.