From 7d31007cd66e99d18ac8e6bb1846b94b79a4b2ad Mon Sep 17 00:00:00 2001 From: codeskyblue Date: Wed, 17 Jun 2015 17:30:30 +0800 Subject: [PATCH] catch more signals instead of just sigint --- start.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/start.go b/start.go index 3a6fe11..716c36d 100644 --- a/start.go +++ b/start.go @@ -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()