Skip to content

Commit dedf2cf

Browse files
committed
fix: proxy fixes
1 parent 72e12aa commit dedf2cf

File tree

6 files changed

+25
-19
lines changed

6 files changed

+25
-19
lines changed

app/Actions/Docker/GetContainersStatus.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,9 @@ private function old_way()
651651
// $this->server->team?->notify(new ContainerStopped($containerName, $this->server, $url));
652652
}
653653

654-
// Check if proxy is running
655-
$this->server->proxyType();
654+
if (! $this->server->proxySet() || $this->server->proxy->force_stop) {
655+
return;
656+
}
656657
$foundProxyContainer = $this->containers->filter(function ($value, $key) {
657658
if ($this->server->isSwarm()) {
658659
return data_get($value, 'Spec.Name') === 'coolify-proxy_traefik';

app/Actions/Proxy/StartProxy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function handle(Server $server, bool $async = true, bool $force = false):
3535
"echo 'Creating required Docker Compose file.'",
3636
"echo 'Starting coolify-proxy.'",
3737
'docker stack deploy -c docker-compose.yml coolify-proxy',
38-
"echo 'Proxy started successfully.'",
38+
"echo 'Successfully started coolify-proxy.'",
3939
]);
4040
} else {
4141
$caddfile = 'import /dynamic/*.caddy';
@@ -53,7 +53,7 @@ public function handle(Server $server, bool $async = true, bool $force = false):
5353
'fi',
5454
"echo 'Starting coolify-proxy.'",
5555
'docker compose up -d --remove-orphans',
56-
"echo 'Proxy started successfully.'",
56+
"echo 'Successfully started coolify-proxy.'",
5757
]);
5858
$commands = $commands->merge(connectProxyToNetworks($server));
5959
}

app/Jobs/ServerCheckJob.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ public function handle()
6969
return 'No containers found.';
7070
}
7171
GetContainersStatus::run($this->server, $this->containers, $containerReplicates);
72-
$this->checkLogDrainContainer();
72+
if ($this->server->isLogDrainEnabled()) {
73+
$this->checkLogDrainContainer();
74+
}
7375
}
7476

7577
} catch (\Throwable $e) {
@@ -115,9 +117,6 @@ private function serverStatus()
115117

116118
private function checkLogDrainContainer()
117119
{
118-
if (! $this->server->isLogDrainEnabled()) {
119-
return;
120-
}
121120
$foundLogDrainContainer = $this->containers->filter(function ($value, $key) {
122121
return data_get($value, 'Name') === '/coolify-log-drain';
123122
})->first();

app/Livewire/Server/Proxy/Status.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public function checkProxy(bool $notification = false)
4949
if ($this->server->proxy->status === 'running') {
5050
$this->polling = false;
5151
$notification && $this->dispatch('success', 'Proxy is running.');
52+
} elseif ($this->server->proxy->status === 'exited' and ! $this->server->proxy->force_stop) {
53+
$notification && $this->dispatch('error', 'Proxy has exited.');
54+
} elseif ($this->server->proxy->force_stop) {
55+
$notification && $this->dispatch('error', 'Proxy is stopped manually.');
5256
} else {
5357
$notification && $this->dispatch('error', 'Proxy is not running.');
5458
}

bootstrap/helpers/proxy.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ function connectProxyToNetworks(Server $server)
9696
"echo 'Connecting coolify-proxy to $network network...'",
9797
"docker network ls --format '{{.Name}}' | grep '^$network$' >/dev/null || docker network create --driver overlay --attachable $network >/dev/null",
9898
"docker network connect $network coolify-proxy >/dev/null 2>&1 || true",
99+
"echo 'Successfully connected coolify-proxy to $network network.'",
100+
"echo 'Proxy started and configured successfully!'",
99101
];
100102
});
101103
} else {
@@ -104,6 +106,8 @@ function connectProxyToNetworks(Server $server)
104106
"echo 'Connecting coolify-proxy to $network network...'",
105107
"docker network ls --format '{{.Name}}' | grep '^$network$' >/dev/null || docker network create --attachable $network >/dev/null",
106108
"docker network connect $network coolify-proxy >/dev/null 2>&1 || true",
109+
"echo 'Successfully connected coolify-proxy to $network network.'",
110+
"echo 'Proxy started and configured successfully!'",
107111
];
108112
});
109113
}
@@ -217,7 +221,6 @@ function generate_default_proxy_configuration(Server $server)
217221
}
218222
} elseif ($proxy_type === 'CADDY') {
219223
$config = [
220-
'version' => '3.8',
221224
'networks' => $array_of_networks->toArray(),
222225
'services' => [
223226
'caddy' => [
@@ -236,12 +239,9 @@ function generate_default_proxy_configuration(Server $server)
236239
'80:80',
237240
'443:443',
238241
],
239-
// "healthcheck" => [
240-
// "test" => "wget -qO- http://localhost:80|| exit 1",
241-
// "interval" => "4s",
242-
// "timeout" => "2s",
243-
// "retries" => 5,
244-
// ],
242+
'labels' => [
243+
'coolify.managed=true',
244+
],
245245
'volumes' => [
246246
'/var/run/docker.sock:/var/run/docker.sock:ro',
247247
"{$proxy_path}/dynamic:/dynamic",

resources/views/livewire/server/proxy/status.blade.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
<x-status.running status="Proxy Running" />
44
@elseif (data_get($server, 'proxy.status') === 'restarting')
55
<x-status.restarting status="Proxy Restarting" />
6-
@else
6+
@elseif (data_get($server, 'proxy.force_stop'))
77
<x-status.stopped status="Proxy Stopped" />
8+
@elseif (data_get($server, 'proxy.status') === 'exited')
9+
<x-status.stopped status="Proxy Exited" />
10+
@else
11+
<x-status.stopped status="Proxy Not Running" />
812
@endif
9-
@if (data_get($server, 'proxy.status') === 'running')
10-
<x-forms.button wire:click='checkProxy(true)'>Refresh</x-forms.button>
11-
@endif
13+
<x-forms.button wire:click='checkProxy(true)'>Refresh</x-forms.button>
1214
</div>

0 commit comments

Comments
 (0)