mirror of https://github.com/prometheus/prometheus
Merge pull request #798 from miekg/hup-signal-handing
Start HUP signal handler earlierpull/800/head
commit
6247bd5a5a
21
main.go
21
main.go
|
@ -247,6 +247,19 @@ func (p *prometheus) reloadConfig() bool {
|
||||||
// down. The method installs an interrupt handler, allowing to trigger a
|
// down. The method installs an interrupt handler, allowing to trigger a
|
||||||
// shutdown by sending SIGTERM to the process.
|
// shutdown by sending SIGTERM to the process.
|
||||||
func (p *prometheus) Serve() {
|
func (p *prometheus) Serve() {
|
||||||
|
// Wait for reload or termination signals. Start the handler for SIGHUP as
|
||||||
|
// early as possible, but ignore it until we are ready to handle reloading
|
||||||
|
// our config.
|
||||||
|
hup := make(chan os.Signal)
|
||||||
|
hupReady := make(chan bool)
|
||||||
|
signal.Notify(hup, syscall.SIGHUP)
|
||||||
|
go func() {
|
||||||
|
<-hupReady
|
||||||
|
for range hup {
|
||||||
|
p.reloadConfig()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
// Start all components.
|
// Start all components.
|
||||||
if err := p.storage.Start(); err != nil {
|
if err := p.storage.Start(); err != nil {
|
||||||
log.Errorln("Error opening memory series storage:", err)
|
log.Errorln("Error opening memory series storage:", err)
|
||||||
|
@ -280,13 +293,7 @@ func (p *prometheus) Serve() {
|
||||||
go p.webService.Run()
|
go p.webService.Run()
|
||||||
|
|
||||||
// Wait for reload or termination signals.
|
// Wait for reload or termination signals.
|
||||||
hup := make(chan os.Signal)
|
close(hupReady) // Unblock SIGHUP handler.
|
||||||
signal.Notify(hup, syscall.SIGHUP)
|
|
||||||
go func() {
|
|
||||||
for range hup {
|
|
||||||
p.reloadConfig()
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
term := make(chan os.Signal)
|
term := make(chan os.Signal)
|
||||||
signal.Notify(term, os.Interrupt, syscall.SIGTERM)
|
signal.Notify(term, os.Interrupt, syscall.SIGTERM)
|
||||||
|
|
Loading…
Reference in New Issue