Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: proxy start process

Andras Bacsai6071412986ae
diff --git a/app/Actions/Proxy/CheckProxy.php b/app/Actions/Proxy/CheckProxy.php
index 84dc4e955d..279fac20e3 100644
--- a/app/Actions/Proxy/CheckProxy.php
+++ b/app/Actions/Proxy/CheckProxy.php
@@ -2,41 +2,50 @@
namespace App\Actions\Proxy;
-use App\Enums\ProxyTypes;
use App\Models\Server;
-use Illuminate\Support\Str;
use Lorisleiva\Actions\Concerns\AsAction;
-use Spatie\Activitylog\Models\Activity;
class CheckProxy
{
use AsAction;
- public function handle(Server $server)
+ public function handle(Server $server, $fromUI = false)
{
if (!$server->isProxyShouldRun()) {
- throw new \Exception("Proxy should not run");
+ if ($fromUI) {
+ throw new \Exception("Proxy should not run. You selected the Custom Proxy.");
+ } else {
+ return false;
+ }
}
$status = getContainerStatus($server, 'coolify-proxy');
if ($status === 'running') {
$server->proxy->set('status', 'running');
$server->save();
- return 'OK';
+ return false;
}
$ip = $server->ip;
if ($server->id === 0) {
$ip = 'host.docker.internal';
}
- $connection = @fsockopen($ip, '80');
- $connection = @fsockopen($ip, '443');
- $port80 = is_resource($connection) && fclose($connection);
- $port443 = is_resource($connection) && fclose($connection);
- ray($ip);
+ $connection80 = @fsockopen($ip, '80');
+ $connection443 = @fsockopen($ip, '443');
+ $port80 = is_resource($connection80) && fclose($connection80);
+ $port443 = is_resource($connection443) && fclose($connection443);
if ($port80) {
- 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>");
+ if ($fromUI) {
+ 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>");
+ } else {
+ return false;
+ }
}
if ($port443) {
- 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>>");
+ if ($fromUI) {
+ 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>");
+ } else {
+ return false;
+ }
}
+ return true;
}
}
diff --git a/app/Actions/Proxy/StartProxy.php b/app/Actions/Proxy/StartProxy.php
index 14b7fefb53..6a67381773 100644
--- a/app/Actions/Proxy/StartProxy.php
+++ b/app/Actions/Proxy/StartProxy.php
@@ -13,8 +13,6 @@ class StartProxy
public function handle(Server $server, bool $async = true): string|Activity
{
try {
- CheckProxy::run($server);
-
$proxyType = $server->proxyType();
$commands = collect([]);
$proxy_path = get_proxy_path();
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index 52bf06ed9b..730cf4113c 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -28,6 +28,7 @@ class Kernel extends ConsoleKernel
// $this->check_scheduled_backups($schedule);
$this->check_resources($schedule);
$this->cleanup_servers($schedule);
+ $this->check_scheduled_backups($schedule);
} else {
$schedule->command('horizon:snapshot')->everyFiveMinutes();
$schedule->job(new CleanupInstanceStuffsJob)->everyTwoMinutes()->onOneServer();
diff --git a/app/Http/Livewire/Server/Proxy/Deploy.php b/app/Http/Livewire/Server/Proxy/Deploy.php
index 39995e0776..7e828b0928 100644
--- a/app/Http/Livewire/Server/Proxy/Deploy.php
+++ b/app/Http/Livewire/Server/Proxy/Deploy.php
@@ -39,7 +39,7 @@ class Deploy extends Component
public function checkProxy()
{
try {
- CheckProxy::run($this->server);
+ CheckProxy::run($this->server, true);
$this->emit('startProxyPolling');
$this->emit('proxyChecked');
} catch (\Throwable $e) {
diff --git a/app/Http/Livewire/Server/Proxy/Status.php b/app/Http/Livewire/Server/Proxy/Status.php
index 90deb14554..8df8f10cdd 100644
--- a/app/Http/Livewire/Server/Proxy/Status.php
+++ b/app/Http/Livewire/Server/Proxy/Status.php
@@ -34,7 +34,7 @@ class Status extends Component
}
$this->numberOfPolls++;
}
- CheckProxy::run($this->server);
+ CheckProxy::run($this->server, true);
$this->emit('proxyStatusUpdated');
if ($this->server->proxy->status === 'running') {
$this->polling = false;
diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php
index 4f379ec65b..1c8cf19191 100644
--- a/app/Jobs/ContainerStatusJob.php
+++ b/app/Jobs/ContainerStatusJob.php
@@ -2,6 +2,7 @@
namespace App\Jobs;
+use App\Actions\Proxy\CheckProxy;
use App\Actions\Proxy\StartProxy;
use App\Models\ApplicationPreview;
use App\Models\Server;
@@ -117,10 +118,18 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted
return data_get($value, 'Name') === '/coolify-proxy';
})->first();
if (!$foundProxyContainer) {
- if ($this->server->isProxyShouldRun()) {
- StartProxy::run($this->server, false);
- $this->server->team->notify(new ContainerRestarted('coolify-proxy', $this->server));
+ try {
+ $shouldStart = CheckProxy::run($this->server);
+ if ($shouldStart) {
+ StartProxy::run($this->server, false);
+ $this->server->team->notify(new ContainerRestarted('coolify-proxy', $this->server));
+ } else {
+ ray('Proxy could not be started.');
+ }
+ } catch (\Throwable $e) {
+ ray($e);
}
+
} else {
$this->server->proxy->status = data_get($foundProxyContainer, 'State.Status');
$this->server->save();
diff --git a/config/sentry.php b/config/sentry.php
index f6f0a29fdf..4a096757fd 100644
--- a/config/sentry.php
+++ b/config/sentry.php
@@ -7,7 +7,7 @@ return [
// The release version of your application
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
- 'release' => '4.0.0-beta.91',
+ 'release' => '4.0.0-beta.92',
// When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'),
diff --git a/config/version.php b/config/version.php
index 286da2a79c..d889b7a6c2 100644
--- a/config/version.php
+++ b/config/version.php
@@ -1,3 +1,3 @@
<?php
-return '4.0.0-beta.91';
+return '4.0.0-beta.92';
diff --git a/versions.json b/versions.json
index 79d2fb2f8e..a78a28277a 100644
--- a/versions.json
+++ b/versions.json
@@ -4,7 +4,7 @@
"version": "3.12.36"
},
"v4": {
- "version": "4.0.0-beta.91"
+ "version": "4.0.0-beta.92"
}
}
}