From cccf86d388f0ea223b02a1803be9d4dec6ce6614 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 22 May 2024 20:42:08 +0200 Subject: [PATCH] feat: if proxy stopped manually, it won't start back again --- app/Actions/Proxy/CheckProxy.php | 4 +++- app/Actions/Proxy/StartProxy.php | 2 +- app/Listeners/ProxyStartedNotification.php | 2 ++ app/Livewire/Server/Proxy/Deploy.php | 10 ++++------ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/Actions/Proxy/CheckProxy.php b/app/Actions/Proxy/CheckProxy.php index 6f0bbddee..8804eba23 100644 --- a/app/Actions/Proxy/CheckProxy.php +++ b/app/Actions/Proxy/CheckProxy.php @@ -13,7 +13,9 @@ class CheckProxy if (!$server->isFunctional()) { return false; } - if ($server->proxyType() === 'NONE') { + $proxyType = $server->proxyType(); + if (is_null($proxyType) || $proxyType === 'NONE' || $server->proxy->force_stop) { + ray('Not starting proxy'); return false; } ['uptime' => $uptime, 'error' => $error] = $server->validateConnection(); diff --git a/app/Actions/Proxy/StartProxy.php b/app/Actions/Proxy/StartProxy.php index 5b1ffa409..3e41708d4 100644 --- a/app/Actions/Proxy/StartProxy.php +++ b/app/Actions/Proxy/StartProxy.php @@ -15,7 +15,7 @@ class StartProxy { try { $proxyType = $server->proxyType(); - if (is_null($proxyType) || $proxyType === 'NONE') { + if (is_null($proxyType) || $proxyType === 'NONE' || $server->proxy->force_stop) { return 'OK'; } $commands = collect([]); diff --git a/app/Listeners/ProxyStartedNotification.php b/app/Listeners/ProxyStartedNotification.php index e6be605ce..1a4fe97bb 100644 --- a/app/Listeners/ProxyStartedNotification.php +++ b/app/Listeners/ProxyStartedNotification.php @@ -17,5 +17,7 @@ class ProxyStartedNotification $this->server = data_get($event, 'data'); $this->server->setupDefault404Redirect(); $this->server->setupDynamicProxyConfiguration(); + $this->server->proxy->force_stop = false; + $this->server->save(); } } diff --git a/app/Livewire/Server/Proxy/Deploy.php b/app/Livewire/Server/Proxy/Deploy.php index 82925c396..2ebaa1a38 100644 --- a/app/Livewire/Server/Proxy/Deploy.php +++ b/app/Livewire/Server/Proxy/Deploy.php @@ -86,17 +86,15 @@ class Deploy extends Component instant_remote_process([ "docker service rm coolify-proxy_traefik", ], $this->server); - $this->server->proxy->status = 'exited'; - $this->server->save(); - $this->dispatch('proxyStatusUpdated'); } else { instant_remote_process([ "docker rm -f coolify-proxy", ], $this->server); - $this->server->proxy->status = 'exited'; - $this->server->save(); - $this->dispatch('proxyStatusUpdated'); } + $this->server->proxy->status = 'exited'; + $this->server->proxy->force_stop = true; + $this->server->save(); + $this->dispatch('proxyStatusUpdated'); } catch (\Throwable $e) { return handleError($e, $this); }