Better handling of stop & restart without releasing process locks too soon

This commit is contained in:
Dane Everitt
2020-08-13 21:10:33 -07:00
parent 5fcec86e98
commit 63c09adaa1
3 changed files with 37 additions and 20 deletions

View File

@@ -106,9 +106,13 @@ func (s *Server) HandlePowerAction(action PowerAction, waitSeconds ...int) error
case PowerActionStart:
return s.Environment.Start()
case PowerActionStop:
return s.Environment.Stop()
// We're specificially waiting for the process to be stopped here, otherwise the lock is released
// too soon, and you can rack up all sorts of issues.
return s.Environment.WaitForStop(10 * 60, true)
case PowerActionRestart:
return s.Environment.Restart()
// Same as stopping, give the process up to 10 minutes to stop before just forcibly terminating
// the process and moving on with things.
return s.Environment.Restart(10 * 60, true)
case PowerActionTerminate:
return s.Environment.Terminate(os.Kill)
}