Catch SIGHUP as early as possible to avoid process termination

Fixes https://github.com/prometheus/prometheus/issues/14917

Signed-off-by: Julius Volz <julius.volz@gmail.com>
This commit is contained in:
Julius Volz 2024-09-17 20:24:21 +02:00
parent b8d1336d42
commit 6b01b7a3f0

View file

@ -260,6 +260,11 @@ func (c *flagConfig) setFeatureListOptions(logger log.Logger) error {
} }
func main() { func main() {
// Catch HUP (reload) signals as early as possible, so that an early HUP
// does not terminate the process.
hup := make(chan os.Signal, 1)
signal.Notify(hup, syscall.SIGHUP)
if os.Getenv("DEBUG") != "" { if os.Getenv("DEBUG") != "" {
runtime.SetBlockProfileRate(20) runtime.SetBlockProfileRate(20)
runtime.SetMutexProfileFraction(20) runtime.SetMutexProfileFraction(20)
@ -1067,11 +1072,6 @@ func main() {
} }
{ {
// Reload handler. // Reload handler.
// Make sure that sighup handler is registered with a redirect to the channel before the potentially
// long and synchronous tsdb init.
hup := make(chan os.Signal, 1)
signal.Notify(hup, syscall.SIGHUP)
cancel := make(chan struct{}) cancel := make(chan struct{})
var checksum string var checksum string