Merge pull request #1338 from coollabsio/next

v4.0.0-beta.92
This commit is contained in:
Andras Bacsai 2023-10-17 19:03:04 +02:00 committed by GitHub
commit 1e39c3d5ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 40 additions and 23 deletions

View File

@ -2,41 +2,50 @@
namespace App\Actions\Proxy; namespace App\Actions\Proxy;
use App\Enums\ProxyTypes;
use App\Models\Server; use App\Models\Server;
use Illuminate\Support\Str;
use Lorisleiva\Actions\Concerns\AsAction; use Lorisleiva\Actions\Concerns\AsAction;
use Spatie\Activitylog\Models\Activity;
class CheckProxy class CheckProxy
{ {
use AsAction; use AsAction;
public function handle(Server $server) public function handle(Server $server, $fromUI = false)
{ {
if (!$server->isProxyShouldRun()) { 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'); $status = getContainerStatus($server, 'coolify-proxy');
if ($status === 'running') { if ($status === 'running') {
$server->proxy->set('status', 'running'); $server->proxy->set('status', 'running');
$server->save(); $server->save();
return 'OK'; return false;
} }
$ip = $server->ip; $ip = $server->ip;
if ($server->id === 0) { if ($server->id === 0) {
$ip = 'host.docker.internal'; $ip = 'host.docker.internal';
} }
$connection = @fsockopen($ip, '80'); $connection80 = @fsockopen($ip, '80');
$connection = @fsockopen($ip, '443'); $connection443 = @fsockopen($ip, '443');
$port80 = is_resource($connection) && fclose($connection); $port80 = is_resource($connection80) && fclose($connection80);
$port443 = is_resource($connection) && fclose($connection); $port443 = is_resource($connection443) && fclose($connection443);
ray($ip);
if ($port80) { 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) { 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;
} }
} }

View File

@ -13,8 +13,6 @@ class StartProxy
public function handle(Server $server, bool $async = true): string|Activity public function handle(Server $server, bool $async = true): string|Activity
{ {
try { try {
CheckProxy::run($server);
$proxyType = $server->proxyType(); $proxyType = $server->proxyType();
$commands = collect([]); $commands = collect([]);
$proxy_path = get_proxy_path(); $proxy_path = get_proxy_path();

View File

@ -28,6 +28,7 @@ protected function schedule(Schedule $schedule): void
// $this->check_scheduled_backups($schedule); // $this->check_scheduled_backups($schedule);
$this->check_resources($schedule); $this->check_resources($schedule);
$this->cleanup_servers($schedule); $this->cleanup_servers($schedule);
$this->check_scheduled_backups($schedule);
} else { } else {
$schedule->command('horizon:snapshot')->everyFiveMinutes(); $schedule->command('horizon:snapshot')->everyFiveMinutes();
$schedule->job(new CleanupInstanceStuffsJob)->everyTwoMinutes()->onOneServer(); $schedule->job(new CleanupInstanceStuffsJob)->everyTwoMinutes()->onOneServer();

View File

@ -39,7 +39,7 @@ public function ip()
public function checkProxy() public function checkProxy()
{ {
try { try {
CheckProxy::run($this->server); CheckProxy::run($this->server, true);
$this->emit('startProxyPolling'); $this->emit('startProxyPolling');
$this->emit('proxyChecked'); $this->emit('proxyChecked');
} catch (\Throwable $e) { } catch (\Throwable $e) {

View File

@ -34,7 +34,7 @@ public function checkProxy(bool $notification = false)
} }
$this->numberOfPolls++; $this->numberOfPolls++;
} }
CheckProxy::run($this->server); CheckProxy::run($this->server, true);
$this->emit('proxyStatusUpdated'); $this->emit('proxyStatusUpdated');
if ($this->server->proxy->status === 'running') { if ($this->server->proxy->status === 'running') {
$this->polling = false; $this->polling = false;

View File

@ -2,6 +2,7 @@
namespace App\Jobs; namespace App\Jobs;
use App\Actions\Proxy\CheckProxy;
use App\Actions\Proxy\StartProxy; use App\Actions\Proxy\StartProxy;
use App\Models\ApplicationPreview; use App\Models\ApplicationPreview;
use App\Models\Server; use App\Models\Server;
@ -117,10 +118,18 @@ public function handle()
return data_get($value, 'Name') === '/coolify-proxy'; return data_get($value, 'Name') === '/coolify-proxy';
})->first(); })->first();
if (!$foundProxyContainer) { if (!$foundProxyContainer) {
if ($this->server->isProxyShouldRun()) { try {
StartProxy::run($this->server, false); $shouldStart = CheckProxy::run($this->server);
$this->server->team->notify(new ContainerRestarted('coolify-proxy', $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 { } else {
$this->server->proxy->status = data_get($foundProxyContainer, 'State.Status'); $this->server->proxy->status = data_get($foundProxyContainer, 'State.Status');
$this->server->save(); $this->server->save();

View File

@ -7,7 +7,7 @@
// The release version of your application // The release version of your application
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) // 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 // When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'), 'environment' => config('app.env'),

View File

@ -1,3 +1,3 @@
<?php <?php
return '4.0.0-beta.91'; return '4.0.0-beta.92';

View File

@ -4,7 +4,7 @@
"version": "3.12.36" "version": "3.12.36"
}, },
"v4": { "v4": {
"version": "4.0.0-beta.91" "version": "4.0.0-beta.92"
} }
} }
} }