mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-21 15:45:01 +00:00
lib/procutil: prevent from app termination on SIGHUP signal, since this signal is frequently used for config reload
This commit is contained in:
parent
67511d4165
commit
825a2dd554
1 changed files with 12 additions and 2 deletions
|
@ -9,8 +9,18 @@ import (
|
||||||
// WaitForSigterm waits for either SIGTERM or SIGINT
|
// WaitForSigterm waits for either SIGTERM or SIGINT
|
||||||
//
|
//
|
||||||
// Returns the caught signal.
|
// Returns the caught signal.
|
||||||
|
//
|
||||||
|
// It also prevent from program termination on SIGHUP signal,
|
||||||
|
// since this signal is frequently used for config reloading.
|
||||||
func WaitForSigterm() os.Signal {
|
func WaitForSigterm() os.Signal {
|
||||||
ch := make(chan os.Signal, 1)
|
ch := make(chan os.Signal, 1)
|
||||||
signal.Notify(ch, os.Interrupt, syscall.SIGTERM)
|
for {
|
||||||
return <-ch
|
signal.Notify(ch, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP)
|
||||||
|
sig := <-ch
|
||||||
|
if sig == syscall.SIGHUP {
|
||||||
|
// Prevent from the program stop on SIGHUP
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return sig
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue