feat: if proxy stopped manually, it won't start back again

This commit is contained in:
Andras Bacsai 2024-05-22 20:42:08 +02:00
parent c102c23831
commit cccf86d388
4 changed files with 10 additions and 8 deletions

View File

@ -13,7 +13,9 @@ public function handle(Server $server, $fromUI = false)
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();

View File

@ -15,7 +15,7 @@ public function handle(Server $server, bool $async = true): string|Activity
{
try {
$proxyType = $server->proxyType();
if (is_null($proxyType) || $proxyType === 'NONE') {
if (is_null($proxyType) || $proxyType === 'NONE' || $server->proxy->force_stop) {
return 'OK';
}
$commands = collect([]);

View File

@ -17,5 +17,7 @@ public function handle(ProxyStarted $event): void
$this->server = data_get($event, 'data');
$this->server->setupDefault404Redirect();
$this->server->setupDynamicProxyConfiguration();
$this->server->proxy->force_stop = false;
$this->server->save();
}
}

View File

@ -86,17 +86,15 @@ public function stop()
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);
}