fix: support capturing SIGTERM signal to shutdown gracefully (#82)
This commit is contained in:
parent
2ed0404e9e
commit
271748ee09
1 changed files with 4 additions and 3 deletions
|
@ -18,6 +18,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hipages/php-fpm_exporter/phpfpm"
|
"github.com/hipages/php-fpm_exporter/phpfpm"
|
||||||
|
@ -93,9 +94,9 @@ to quickly create a Cobra application.`,
|
||||||
}()
|
}()
|
||||||
|
|
||||||
c := make(chan os.Signal, 1)
|
c := make(chan os.Signal, 1)
|
||||||
// We'll accept graceful shutdowns when quit via SIGINT (Ctrl+C)
|
// We'll accept graceful shutdowns when quit via SIGINT (Ctrl+C) or SIGTERM
|
||||||
// SIGKILL, SIGQUIT or SIGTERM (Ctrl+/) will not be caught.
|
// SIGKILL, SIGQUIT will not be caught.
|
||||||
signal.Notify(c, os.Interrupt)
|
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||||
|
|
||||||
// Block until we receive our signal.
|
// Block until we receive our signal.
|
||||||
<-c
|
<-c
|
||||||
|
|
Loading…
Reference in a new issue