Merge pull request #2842 from Roasbeef/catch-all-signals
signal: catch all termination signals by default
This commit is contained in:
commit
55ddca6d2f
@ -8,6 +8,7 @@ package signal
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -26,7 +27,15 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
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()
|
go mainInterruptHandler()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,8 +69,8 @@ func mainInterruptHandler() {
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-interruptChannel:
|
case signal := <-interruptChannel:
|
||||||
log.Infof("Received SIGINT (Ctrl+C).")
|
log.Infof("Received %v", signal)
|
||||||
shutdown()
|
shutdown()
|
||||||
|
|
||||||
case <-shutdownRequestChannel:
|
case <-shutdownRequestChannel:
|
||||||
|
Loading…
Reference in New Issue
Block a user