server->uuid))->expireAfter(60)->dontRelease()]; } public function __construct(public Server $server) {} public function handle() { try { // Set status to restarting and notify UI immediately $this->server->proxy->status = 'restarting'; $this->server->save(); ProxyStatusChangedUI::dispatch($this->server->team_id); // Stop proxy StopProxy::run($this->server, restarting: true); // Clear force_stop flag $this->server->proxy->force_stop = false; $this->server->save(); // Start proxy asynchronously - returns Activity immediately // The ProxyStatusChanged event will be dispatched when the remote process completes, // which triggers ProxyStatusChangedNotification listener $activity = StartProxy::run($this->server, force: true, restarting: true); // Dispatch event with activity ID immediately so UI can show logs in real-time if ($activity && is_object($activity)) { $this->activity_id = $activity->id; ProxyStatusChangedUI::dispatch($this->server->team_id, $this->activity_id); } } catch (\Throwable $e) { // Set error status $this->server->proxy->status = 'error'; $this->server->save(); // Notify UI of error ProxyStatusChangedUI::dispatch($this->server->team_id); return handleError($e); } } }