Skip to content

Commit 7442d19

Browse files
authored
Merge pull request coollabsio#3705 from coollabsio/next
v4.0.0-beta.354
2 parents 82c8349 + d990a56 commit 7442d19

File tree

19 files changed

+125
-44
lines changed

19 files changed

+125
-44
lines changed

app/Actions/Proxy/CheckProxy.php

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22

33
namespace App\Actions\Proxy;
44

5+
use App\Enums\ProxyTypes;
56
use App\Models\Server;
67
use Lorisleiva\Actions\Concerns\AsAction;
8+
use Symfony\Component\Yaml\Yaml;
79

810
class CheckProxy
911
{
1012
use AsAction;
1113

12-
public function handle(Server $server, $fromUI = false)
14+
// It should return if the proxy should be started (true) or not (false)
15+
public function handle(Server $server, $fromUI = false): bool
1316
{
1417
if (! $server->isFunctional()) {
1518
return false;
@@ -62,22 +65,42 @@ public function handle(Server $server, $fromUI = false)
6265
$ip = 'host.docker.internal';
6366
}
6467

65-
$connection80 = @fsockopen($ip, '80');
66-
$connection443 = @fsockopen($ip, '443');
67-
$port80 = is_resource($connection80) && fclose($connection80);
68-
$port443 = is_resource($connection443) && fclose($connection443);
69-
if ($port80) {
70-
if ($fromUI) {
71-
throw new \Exception("Port 80 is in use.<br>You must stop the process using this port.<br>Docs: <a target='_blank' href='https://coolify.io/docs'>https://coolify.io/docs</a><br>Discord: <a target='_blank' href='https://coollabs.io/discord'>https://coollabs.io/discord</a>");
68+
$portsToCheck = ['80', '443'];
69+
70+
try {
71+
if ($server->proxyType() !== ProxyTypes::NONE->value) {
72+
$proxyCompose = CheckConfiguration::run($server);
73+
if (isset($proxyCompose)) {
74+
$yaml = Yaml::parse($proxyCompose);
75+
$portsToCheck = [];
76+
if ($server->proxyType() === ProxyTypes::TRAEFIK->value) {
77+
$ports = data_get($yaml, 'services.traefik.ports');
78+
} elseif ($server->proxyType() === ProxyTypes::CADDY->value) {
79+
$ports = data_get($yaml, 'services.caddy.ports');
80+
}
81+
if (isset($ports)) {
82+
foreach ($ports as $port) {
83+
$portsToCheck[] = str($port)->before(':')->value();
84+
}
85+
}
86+
}
7287
} else {
73-
return false;
88+
$portsToCheck = [];
7489
}
90+
} catch (\Exception $e) {
91+
ray($e->getMessage());
7592
}
76-
if ($port443) {
77-
if ($fromUI) {
78-
throw new \Exception("Port 443 is in use.<br>You must stop the process using this port.<br>Docs: <a target='_blank' href='https://coolify.io/docs'>https://coolify.io/docs</a><br>Discord: <a target='_blank' href='https://coollabs.io/discord'>https://coollabs.io/discord</a>");
79-
} else {
80-
return false;
93+
if (count($portsToCheck) === 0) {
94+
return false;
95+
}
96+
foreach ($portsToCheck as $port) {
97+
$connection = @fsockopen($ip, $port);
98+
if (is_resource($connection) && fclose($connection)) {
99+
if ($fromUI) {
100+
throw new \Exception("Port $port is in use.<br>You must stop the process using this port.<br>Docs: <a target='_blank' href='https://coolify.io/docs'>https://coolify.io/docs</a><br>Discord: <a target='_blank' href='https://coollabs.io/discord'>https://coollabs.io/discord</a>");
101+
} else {
102+
return false;
103+
}
81104
}
82105
}
83106

app/Console/Commands/CheckApplicationDeploymentQueue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function handle()
1818
$deployments = ApplicationDeploymentQueue::whereIn('status', [
1919
ApplicationDeploymentStatus::IN_PROGRESS,
2020
ApplicationDeploymentStatus::QUEUED,
21-
])->where('created_at', '>=', now()->subSeconds($seconds))->get();
21+
])->where('created_at', '<=', now()->subSeconds($seconds))->get();
2222
if ($deployments->isEmpty()) {
2323
$this->info('No deployments found in the last '.$seconds.' seconds.');
2424

app/Livewire/Server/Proxy/Status.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use App\Actions\Docker\GetContainersStatus;
66
use App\Actions\Proxy\CheckProxy;
7-
use App\Jobs\ContainerStatusJob;
7+
use App\Actions\Proxy\StartProxy;
88
use App\Models\Server;
99
use Livewire\Component;
1010

@@ -44,7 +44,10 @@ public function checkProxy(bool $notification = false)
4444
}
4545
$this->numberOfPolls++;
4646
}
47-
CheckProxy::run($this->server, true);
47+
$shouldStart = CheckProxy::run($this->server, true);
48+
if ($shouldStart) {
49+
StartProxy::run($this->server, false);
50+
}
4851
$this->dispatch('proxyStatusUpdated');
4952
if ($this->server->proxy->status === 'running') {
5053
$this->polling = false;

app/Models/Server.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -460,15 +460,6 @@ public function proxyPath()
460460

461461
public function proxyType()
462462
{
463-
// $proxyType = $this->proxy->get('type');
464-
// if ($proxyType === ProxyTypes::NONE->value) {
465-
// return $proxyType;
466-
// }
467-
// if (is_null($proxyType)) {
468-
// $this->proxy->type = ProxyTypes::TRAEFIK->value;
469-
// $this->proxy->status = ProxyStatus::EXITED->value;
470-
// $this->save();
471-
// }
472463
return data_get($this->proxy, 'type');
473464
}
474465

app/Models/Service.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,6 @@ public function extraFields()
797797
}
798798
}
799799
$databases = $this->databases()->get();
800-
ray($databases);
801800

802801
foreach ($databases as $database) {
803802
$image = str($database->image)->before(':')->value();

config/sentry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
// The release version of your application
99
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
10-
'release' => '4.0.0-beta.353',
10+
'release' => '4.0.0-beta.354',
1111
// When left empty or `null` the Laravel environment will be used
1212
'environment' => config('app.env'),
1313

config/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<?php
22

3-
return '4.0.0-beta.353';
3+
return '4.0.0-beta.354';

other/nightly/versions.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"coolify": {
33
"v4": {
4-
"version": "4.0.0-beta.350"
4+
"version": "4.0.0-beta.354"
55
},
66
"nightly": {
7-
"version": "4.0.0-beta.351"
7+
"version": "4.0.0-beta.355"
88
},
99
"helper": {
1010
"version": "1.0.1"

public/svgs/homarr.svg

Lines changed: 11 additions & 0 deletions
Loading

public/svgs/it-tools.svg

Lines changed: 6 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)