diff --git a/router/websocket/websocket.go b/router/websocket/websocket.go index 4d5036b..77353d8 100644 --- a/router/websocket/websocket.go +++ b/router/websocket/websocket.go @@ -174,7 +174,9 @@ func (h *Handler) TokenValid() error { // error message, otherwise we just send back a standard error message. func (h *Handler) SendErrorJson(msg Message, err error, shouldLog ...bool) error { j := h.GetJwt() - expected := errors.Is(err, server.ErrSuspended) || errors.Is(err, server.ErrIsRunning) + expected := errors.Is(err, server.ErrSuspended) || + errors.Is(err, server.ErrIsRunning) || + errors.Is(err, server.ErrNotEnoughDiskSpace) message := "an unexpected error was encountered while handling this request" if expected || (j != nil && j.HasPermission(PermissionReceiveErrors)) { diff --git a/server/power.go b/server/power.go index a46aa84..35e8d5f 100644 --- a/server/power.go +++ b/server/power.go @@ -38,6 +38,21 @@ func (pa PowerAction) IsStart() bool { return pa == PowerActionStart || pa == PowerActionRestart } +// Check if there is currently a power action being processed for the server. +func (s *Server) ExecutingPowerAction() bool { + if s.powerLock == nil { + return false + } + + ok := s.powerLock.TryAcquire(1) + if ok { + s.powerLock.Release(1) + } + + // Remember, if we acquired a lock it means nothing was running. + return !ok +} + // Helper function that can receive a power action and then process the actions that need // to occur for it. This guards against someone calling Start() twice at the same time, or // trying to restart while another restart process is currently running.