Merge pull request #2842 from Roasbeef/catch-all-signals

signal: catch all termination signals by default
This commit is contained in:
Olaoluwa Osuntokun 2019-03-27 13:26:13 -07:00 committed by GitHub
commit 55ddca6d2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,6 +8,7 @@ package signal
import (
"os"
"os/signal"
"syscall"
)
var (
@ -26,7 +27,15 @@ var (
)
func init() {
signal.Notify(interruptChannel, os.Interrupt)
signalsToCatch := []os.Signal{
os.Interrupt,
os.Kill,
syscall.SIGABRT,
syscall.SIGTERM,
syscall.SIGSTOP,
syscall.SIGQUIT,
}
signal.Notify(interruptChannel, signalsToCatch...)
go mainInterruptHandler()
}
@ -60,8 +69,8 @@ func mainInterruptHandler() {
for {
select {
case <-interruptChannel:
log.Infof("Received SIGINT (Ctrl+C).")
case signal := <-interruptChannel:
log.Infof("Received %v", signal)
shutdown()
case <-shutdownRequestChannel: