fermentord/pkg/daemon/wait.go

25 lines
398 B
Go
Raw Normal View History

2021-11-16 05:19:24 +00:00
package daemon
import (
"os"
"os/signal"
"syscall"
)
var (
Interrupt = os.Interrupt
Quit os.Signal = syscall.SIGQUIT
Terminate os.Signal = syscall.SIGTERM
)
2022-02-18 20:59:32 +00:00
func WaitForSignal(sig ...os.Signal) os.Signal {
2021-11-16 05:19:24 +00:00
ch := make(chan os.Signal, 1)
signal.Notify(ch, sig...)
2022-02-18 20:59:32 +00:00
return <-ch
2021-11-16 05:19:24 +00:00
}
2022-02-18 20:59:32 +00:00
func WaitForSignalsDefault() os.Signal {
return WaitForSignal(Interrupt, Quit, Terminate)
2021-11-16 05:19:24 +00:00
}