mirror of
https://github.com/beego/bee.git
synced 2024-11-23 22:10:54 +00:00
When restarting, terminate process gracefully
This commit is contained in:
parent
e3e401cadd
commit
8252ea9f88
@ -148,7 +148,7 @@ func AutoBuild(files []string, isgenerate bool) {
|
|||||||
}
|
}
|
||||||
appName := appname
|
appName := appname
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
appName += ".exe"
|
appName += ".exe"
|
||||||
}
|
}
|
||||||
@ -183,9 +183,20 @@ func Kill() {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
if cmd != nil && cmd.Process != nil {
|
if cmd != nil && cmd.Process != nil {
|
||||||
err := cmd.Process.Kill()
|
//err := cmd.Process.Kill()
|
||||||
if err != nil {
|
cmd.Process.Signal(os.Interrupt)
|
||||||
beeLogger.Log.Errorf("Error while killing cmd process: %s", err)
|
ch := make(chan struct{}, 1)
|
||||||
|
go func() {
|
||||||
|
cmd.Wait()
|
||||||
|
ch <- struct{}{}
|
||||||
|
}()
|
||||||
|
select {
|
||||||
|
case <-ch:
|
||||||
|
return
|
||||||
|
case <-time.After(10 * time.Second):
|
||||||
|
beeLogger.Log.Info("Timeout; Force kill cmd process")
|
||||||
|
cmd.Process.Kill()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user