mirror of
https://github.com/beego/bee.git
synced 2024-11-24 03:20:55 +00:00
When restarting, terminate process gracefully
This commit is contained in:
parent
e3e401cadd
commit
8252ea9f88
@ -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