From 825a2dd554bf6c27aaed0616fa6b6a2a61f06124 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 30 Apr 2020 02:09:27 +0300 Subject: [PATCH] lib/procutil: prevent from app termination on SIGHUP signal, since this signal is frequently used for config reload --- lib/procutil/signal.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/procutil/signal.go b/lib/procutil/signal.go index 850f4c3a4..8221ecb67 100644 --- a/lib/procutil/signal.go +++ b/lib/procutil/signal.go @@ -9,8 +9,18 @@ import ( // WaitForSigterm waits for either SIGTERM or SIGINT // // 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 { ch := make(chan os.Signal, 1) - signal.Notify(ch, os.Interrupt, syscall.SIGTERM) - return <-ch + for { + 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 + } }