mirror of
https://github.com/beego/bee.git
synced 2024-11-21 23:50:54 +00:00
Merge pull request #569 from sangheee/develop
Kill the server process gracefully
This commit is contained in:
commit
12019e22af
@ -183,10 +183,23 @@ func Kill() {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
if cmd != nil && cmd.Process != nil {
|
if cmd != nil && cmd.Process != nil {
|
||||||
|
cmd.Process.Signal(os.Interrupt)
|
||||||
|
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")
|
||||||
err := cmd.Process.Kill()
|
err := cmd.Process.Kill()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
beeLogger.Log.Errorf("Error while killing cmd process: %s", err)
|
beeLogger.Log.Errorf("Error while killing cmd process: %s", err)
|
||||||
}
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user