isSuspended()) { return; } // A transfer can race with Wings state synchronization, so reject it first. throw_if($server->transfer !== null, ConflictHttpException::class, 'Cannot toggle suspension status on a server that is currently being transferred.'); $server->update(['status' => $isSuspending ? Server::STATUS_SUSPENDED : null]); try { Daemon::server($server)->sync(); } catch (Exception $exception) { // Restore the Panel state if Wings could not accept the update. $server->update(['status' => $isSuspending ? null : Server::STATUS_SUSPENDED]); throw $exception; } // Only a state change Wings accepted is reported; repeats and reverted attempts are not. Event::dispatch(new OperationCompleted($server->uuid, $isSuspending ? 'suspend' : 'unsuspend', true, $server->uuid)); } }