catch more signals instead of just sigint

This commit is contained in:
codeskyblue
2016-04-13 13:13:10 -07:00
committed by David Dollar
parent dd6e9899ca
commit 7d31007cd6
+5 -3
View File
@@ -9,6 +9,7 @@ import (
"strconv"
"strings"
"sync"
"syscall"
"time"
)
@@ -100,15 +101,16 @@ type Forego struct {
func (f *Forego) monitorInterrupt() {
handler := make(chan os.Signal, 1)
signal.Notify(handler, os.Interrupt)
signal.Notify(handler, syscall.SIGALRM, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)
first := true
for sig := range handler {
switch sig {
case os.Interrupt:
case syscall.SIGINT:
fmt.Println(" | ctrl-c detected")
fallthrough
default:
f.teardown.Fall()
if !first {
f.teardownNow.Fall()