Require a lock on the restart process to avoid double restarts causing unexpected behavior

This commit is contained in:
Dane Everitt
2020-07-18 16:46:41 -07:00
parent 6de18f09e5
commit a00288aa64
4 changed files with 92 additions and 11 deletions

View File

@@ -283,11 +283,14 @@ func (h *Handler) HandleInbound(m Message) error {
break
case "restart":
if h.GetJwt().HasPermission(PermissionSendPowerRestart) {
if err := h.server.Environment.WaitForStop(60, false); err != nil {
return err
// If the server is alreay restarting don't do anything. Perhaps we send back an event
// in the future for this? For now no reason to knowingly trigger an error by trying to
// restart a process already restarting.
if h.server.Environment.IsRestarting() {
return nil
}
return h.server.Environment.Start()
return h.server.Environment.Restart()
}
break
case "kill":