Implement graceful shutdown
This commit is contained in:
parent
3b401c413b
commit
3d9e7286de
10
main.go
10
main.go
|
@ -16,6 +16,9 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/prometheus/common/log"
|
||||
"github.com/prometheus/common/route"
|
||||
|
@ -73,5 +76,10 @@ func main() {
|
|||
|
||||
NewAPI(router.WithPrefix("/api"), alerts, silences)
|
||||
|
||||
http.ListenAndServe(":9091", router)
|
||||
go http.ListenAndServe(":9091", router)
|
||||
|
||||
term := make(chan os.Signal)
|
||||
signal.Notify(term, os.Interrupt, syscall.SIGTERM)
|
||||
<-term
|
||||
log.Warn("Received SIGTERM, exiting gracefully...")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue