From adede19a119e7f38be29f92948f4e3b77df2310a Mon Sep 17 00:00:00 2001 From: WithLin Date: Mon, 29 Oct 2018 10:25:21 +0800 Subject: [PATCH] Fix app should exit --- cmd/soar/soar.go | 2 +- common/signal.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/soar/soar.go b/cmd/soar/soar.go index f097962..7ba0bbd 100644 --- a/cmd/soar/soar.go +++ b/cmd/soar/soar.go @@ -92,7 +92,7 @@ func main() { } //当程序卡死的时候,或者由于某些原因程序没有退出,可以通过捕获信号量的形式让程序优雅退出并且清理测试环境 - go common.SignalNotify(func() { + common.HandleSignal(func() { if common.Config.DropTestTemporary { vEnv.CleanUp() } diff --git a/common/signal.go b/common/signal.go index f71d93b..4329c96 100644 --- a/common/signal.go +++ b/common/signal.go @@ -20,10 +20,11 @@ import ( "os" "os/signal" "syscall" + "time" ) //当程序卡死的时候,或者由于某些原因程序没有退出,可以通过捕获信号量的形式让程序优雅退出并且清理测试环境 -func SignalNotify(f func()) { +func HandleSignal(f func()) { sc := make(chan os.Signal, 1) signal.Notify(sc, syscall.SIGHUP, @@ -37,6 +38,8 @@ func SignalNotify(f func()) { case n := <-sc: Log.Info("receive signal %v, closing", n) f() + time.Sleep(250 * time.Millisecond) + os.Exit(0) } }() } -- GitLab