mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-18 03:20:26 +00:00
Make proxy restart run as background job to prevent localhost lockout
When restarting the proxy on localhost (where Coolify is running), the UI becomes inaccessible because the connection is lost. This change makes all proxy restarts run as background jobs with WebSocket notifications, allowing the operation to complete even after connection loss. Changes: - Enhanced ProxyStatusChangedUI event to carry activityId for log monitoring - Updated RestartProxyJob to dispatch status events and track activity - Simplified Navbar restart() to always dispatch job for all servers - Enhanced showNotification() to handle activity monitoring and new statuses - Added comprehensive unit and feature tests Benefits: - Prevents localhost lockout during proxy restarts - Consistent behavior across all server types - Non-blocking UI with real-time progress updates - Automatic activity log monitoring - Proper error handling and recovery 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,8 @@ use App\Actions\Proxy\CheckProxy;
|
||||
use App\Actions\Proxy\StartProxy;
|
||||
use App\Actions\Proxy\StopProxy;
|
||||
use App\Enums\ProxyTypes;
|
||||
use App\Jobs\CheckTraefikVersionForServerJob;
|
||||
use App\Jobs\RestartProxyJob;
|
||||
use App\Models\Server;
|
||||
use App\Services\ProxyDashboardCacheService;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
@@ -61,13 +63,11 @@ class Navbar extends Component
|
||||
{
|
||||
try {
|
||||
$this->authorize('manageProxy', $this->server);
|
||||
StopProxy::run($this->server, restarting: true);
|
||||
|
||||
$this->server->proxy->force_stop = false;
|
||||
$this->server->save();
|
||||
// Always use background job for all servers
|
||||
RestartProxyJob::dispatch($this->server);
|
||||
$this->dispatch('info', 'Proxy restart initiated. Monitor progress in activity logs.');
|
||||
|
||||
$activity = StartProxy::run($this->server, force: true, restarting: true);
|
||||
$this->dispatch('activityMonitor', $activity->id);
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
@@ -122,12 +122,17 @@ class Navbar extends Component
|
||||
}
|
||||
}
|
||||
|
||||
public function showNotification()
|
||||
public function showNotification($event = null)
|
||||
{
|
||||
$previousStatus = $this->proxyStatus;
|
||||
$this->server->refresh();
|
||||
$this->proxyStatus = $this->server->proxy->status ?? 'unknown';
|
||||
|
||||
// If event contains activityId, open activity monitor
|
||||
if ($event && isset($event['activityId'])) {
|
||||
$this->dispatch('activityMonitor', $event['activityId']);
|
||||
}
|
||||
|
||||
switch ($this->proxyStatus) {
|
||||
case 'running':
|
||||
$this->loadProxyConfiguration();
|
||||
@@ -150,6 +155,12 @@ class Navbar extends Component
|
||||
case 'starting':
|
||||
$this->dispatch('info', 'Proxy is starting.');
|
||||
break;
|
||||
case 'restarting':
|
||||
$this->dispatch('info', 'Proxy is restarting.');
|
||||
break;
|
||||
case 'error':
|
||||
$this->dispatch('error', 'Proxy restart failed. Check logs.');
|
||||
break;
|
||||
case 'unknown':
|
||||
$this->dispatch('info', 'Proxy status is unknown.');
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user