Rename daemon wait

This commit is contained in:
Søren Rasmussen 2022-04-05 21:05:40 +02:00
parent 6764bd3005
commit 6b36d76c31

View file

@ -15,16 +15,19 @@ var (
) )
// WaitForSignal waits until one of the specified signals are received. // WaitForSignal waits until one of the specified signals are received.
func WaitForSignal(sig ...os.Signal) { func WaitForSignal(sig ...os.Signal) os.Signal {
ch := make(chan os.Signal, 1) ch := make(chan os.Signal, 1)
signal.Notify(ch, sig...) signal.Notify(ch, sig...)
s := <-ch s := <-ch
log.Debug(). log.Debug().
Str("signal", s.String()). Str("signal", s.String()).
Msg("Signal caught") Msg("Signal caught")
return s
} }
// WaitForDefaultSignals waits until one of SIGINT, SIGQUIT or SIGTERM is received. // WaitForSignalsDefault waits until one of SIGINT, SIGQUIT or SIGTERM is received.
func WaitForDefaultSignals() { func WaitForSignalsDefault() {
WaitForSignal(Interrupt, Quit, Terminate) WaitForSignal(Interrupt, Quit, Terminate)
} }