Dispatch restarting status immediately when job starts

Set proxy status to 'restarting' and dispatch ProxyStatusChangedUI event
at the very beginning of handle() method, before StopProxy runs. This
notifies the UI immediately so users know a restart is in progress,
rather than waiting until after the stop operation completes.

Also simplified unit tests to focus on testable job configuration
(middleware, tries, timeout) without complex SchemalessAttributes mocking.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Andras BacsaiandClaude committed 2025-12-03 16:18:13 +01:00
1 parent c42fb81347
commit 340e42aefd
2 files changed
+30 -135

No files matched your search

+9 -5
View File
@@ -34,6 +34,11 @@ class RestartProxyJob implements ShouldBeEncrypted, ShouldQueue
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);
@@ -41,15 +46,14 @@ class RestartProxyJob implements ShouldBeEncrypted, ShouldQueue
$this->server->proxy->force_stop = false;
$this->server->save();
// Start proxy asynchronously - the ProxyStatusChanged event will be dispatched
// when the remote process completes, which triggers ProxyStatusChangedNotification
// listener that handles UI updates and Traefik version checks
// 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);
// Store activity ID and dispatch event with it so UI can open activity monitor
// Dispatch event with activity ID immediately so UI can show logs in real-time
if ($activity && is_object($activity)) {
$this->activity_id = $activity->id;
// Dispatch event with activity ID so the UI can show logs
ProxyStatusChangedUI::dispatch($this->server->team_id, $this->activity_id);
}