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: errors

Andras Bacsai964696910750
diff --git a/app/Http/Livewire/Server/Form.php b/app/Http/Livewire/Server/Form.php
index cdb00c0a25..9794610fed 100644
--- a/app/Http/Livewire/Server/Form.php
+++ b/app/Http/Livewire/Server/Form.php
@@ -15,6 +15,7 @@ class Form extends Component
public $dockerVersion;
public string|null $wildcard_domain = null;
public int $cleanup_after_percentage;
+ public bool $dockerInstallationStarted = false;
protected $rules = [
'server.name' => 'required|min:6',
@@ -44,6 +45,7 @@ class Form extends Component
public function installDocker()
{
+ $this->dockerInstallationStarted = true;
$activity = resolve(InstallDocker::class)($this->server);
$this->emit('newMonitorActivity', $activity->id);
}
@@ -56,7 +58,10 @@ class Form extends Component
$this->uptime = $uptime;
$this->emit('success', 'Server is reachable.');
} else {
+ ray($this->uptime);
+
$this->emit('error', 'Server is not reachable.');
+
return;
}
if ($dockerVersion) {
diff --git a/app/Http/Livewire/Server/Proxy/Status.php b/app/Http/Livewire/Server/Proxy/Status.php
index f808fdb814..0617280495 100644
--- a/app/Http/Livewire/Server/Proxy/Status.php
+++ b/app/Http/Livewire/Server/Proxy/Status.php
@@ -2,6 +2,7 @@
namespace App\Http\Livewire\Server\Proxy;
+use App\Jobs\ContainerStatusJob;
use App\Models\Server;
use Livewire\Component;
@@ -18,9 +19,7 @@ class Status extends Component
{
try {
if ($this->server->isFunctional()) {
- $container = getContainerStatus(server: $this->server, container_id: 'coolify-proxy');
- $this->server->proxy->status = $container;
- $this->server->save();
+ dispatch_sync(new ContainerStatusJob($this->server));
$this->emit('proxyStatusUpdated');
}
} catch (\Throwable $e) {
diff --git a/app/Http/Livewire/Server/ShowPrivateKey.php b/app/Http/Livewire/Server/ShowPrivateKey.php
index c9054f7df7..a0aa6e1e2e 100644
--- a/app/Http/Livewire/Server/ShowPrivateKey.php
+++ b/app/Http/Livewire/Server/ShowPrivateKey.php
@@ -37,14 +37,27 @@ class ShowPrivateKey extends Component
try {
['uptime' => $uptime, 'dockerVersion' => $dockerVersion] = validateServer($this->server, true);
if ($uptime) {
+ $this->server->settings->update([
+ 'is_reachable' => true
+ ]);
$this->emit('success', 'Server is reachable with this private key.');
} else {
+ $this->server->settings->update([
+ 'is_reachable' => false,
+ 'is_usable' => false
+ ]);
$this->emit('error', 'Server is not reachable with this private key.');
return;
}
if ($dockerVersion) {
+ $this->server->settings->update([
+ 'is_usable' => true
+ ]);
$this->emit('success', 'Server is usable for Coolify.');
} else {
+ $this->server->settings->update([
+ 'is_usable' => false
+ ]);
$this->emit('error', 'Old (lower than 23) or no Docker version detected. Install Docker Engine on the General tab.');
}
} catch (\Throwable $e) {
diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php
index 6d5feb5ce7..1cfcdd18af 100644
--- a/app/Jobs/ContainerStatusJob.php
+++ b/app/Jobs/ContainerStatusJob.php
@@ -51,7 +51,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted
try {
// ray()->clearAll();
$serverUptimeCheckNumber = 0;
- $serverUptimeCheckNumberMax = 5;
+ $serverUptimeCheckNumberMax = 3;
while (true) {
if ($serverUptimeCheckNumber >= $serverUptimeCheckNumberMax) {
$this->server->settings()->update(['is_reachable' => false]);
@@ -65,6 +65,10 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted
$serverUptimeCheckNumber++;
sleep(5);
}
+ $containers = instant_remote_process(["docker container ls -q"], $this->server);
+ if (!$containers) {
+ return;
+ }
$containers = instant_remote_process(["docker container inspect $(docker container ls -q) --format '{{json .}}'"], $this->server);
$containers = format_docker_command_output_to_json($containers);
$applications = $this->server->applications();
diff --git a/bootstrap/helpers/remoteProcess.php b/bootstrap/helpers/remoteProcess.php
index ae16c7bc0a..7017ead106 100644
--- a/bootstrap/helpers/remoteProcess.php
+++ b/bootstrap/helpers/remoteProcess.php
@@ -7,15 +7,13 @@ use App\Models\Application;
use App\Models\ApplicationDeploymentQueue;
use App\Models\PrivateKey;
use App\Models\Server;
-use App\Notifications\Server\NotReachable;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Process;
use Illuminate\Support\Facades\Storage;
-use Illuminate\Support\Sleep;
-use Spatie\Activitylog\Models\Activity;
use Illuminate\Support\Str;
+use Spatie\Activitylog\Contracts\Activity;
function remote_process(
array $command,
@@ -110,11 +108,28 @@ function instant_remote_process(array $command, Server $server, $throwError = tr
if (!$throwError) {
return null;
}
- throw new \RuntimeException($process->errorOutput(), $exitCode);
+ return excludeCertainErrors($process->errorOutput(), $exitCode);
}
return $output;
}
-
+function excludeCertainErrors(string $errorOutput, ?int $exitCode = null) {
+ $ignoredErrors = collect([
+ 'Permission denied (publickey',
+ 'Could not resolve hostname',
+ ]);
+ $ignored = false;
+ foreach ($ignoredErrors as $ignoredError) {
+ if (Str::contains($errorOutput, $ignoredError)) {
+ $ignored = true;
+ break;
+ }
+ }
+ if ($ignored) {
+ // TODO: Create new exception and disable in sentry
+ throw new \RuntimeException($errorOutput, $exitCode);
+ }
+ throw new \RuntimeException($errorOutput, $exitCode);
+}
function decode_remote_command_output(?ApplicationDeploymentQueue $application_deployment_queue = null): Collection
{
$application = Application::find(data_get($application_deployment_queue, 'application_id'));
diff --git a/resources/views/components/server/navbar.blade.php b/resources/views/components/server/navbar.blade.php
index 5aaafead1a..baac76ea4f 100644
--- a/resources/views/components/server/navbar.blade.php
+++ b/resources/views/components/server/navbar.blade.php
@@ -1,5 +1,5 @@
<div class="pb-6">
- <livewire:server.proxy.modal :server="$server" />
+ <livewire:server.proxy.modal :server="$server" />
<div class="flex items-center gap-2">
<h1>Server</h1>
@if ($server->settings->is_reachable)
diff --git a/resources/views/livewire/server/form.blade.php b/resources/views/livewire/server/form.blade.php
index ebb40f78f4..4f3df85c2f 100644
--- a/resources/views/livewire/server/form.blade.php
+++ b/resources/views/livewire/server/form.blade.php
@@ -48,10 +48,16 @@
</x-forms.button>
@endif
@if ($server->settings->is_reachable && !$server->settings->is_usable && $server->id !== 0)
- <x-forms.button class="mt-8 mb-4 box" onclick="installDocker.showModal()" wire:click.prevent='installDocker'
- isHighlighted>
- Install Docker Engine 24.0
- </x-forms.button>
+ @if ($dockerInstallationStarted)
+ <x-forms.button class="mt-8 mb-4 box" wire:click.prevent='validateServer'>
+ Validate Server
+ </x-forms.button>
+ @else
+ <x-forms.button class="mt-8 mb-4 box" onclick="installDocker.showModal()"
+ wire:click.prevent='installDocker' isHighlighted>
+ Install Docker Engine 24.0
+ </x-forms.button>
+ @endif
@endif
@if ($server->isFunctional())
<h3 class="py-4">Settings</h3>
diff --git a/resources/views/livewire/server/proxy/status.blade.php b/resources/views/livewire/server/proxy/status.blade.php
index db496f561b..a8eca1a2b4 100644
--- a/resources/views/livewire/server/proxy/status.blade.php
+++ b/resources/views/livewire/server/proxy/status.blade.php
@@ -1,4 +1,3 @@
-
<div class="flex gap-2" x-init="$wire.getProxyStatus">
@if ($server->proxy->status === 'running')
<x-status.running text="Proxy Running" />
@@ -7,7 +6,8 @@
@else
<x-status.stopped text="Proxy Stopped" />
@endif
- <button wire:click.prevent='getProxyStatusWithNoti'><svg class="icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
+ <button wire:loading.remove.delay.longer wire:click.prevent='getProxyStatusWithNoti'>
+ <svg class="icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<g fill="#FCD44F">
<path
d="M12.079 3v-.75V3Zm-8.4 8.333h-.75h.75Zm0 1.667l-.527.532a.75.75 0 0 0 1.056 0L3.68 13Zm2.209-1.134A.75.75 0 1 0 4.83 10.8l1.057 1.065ZM2.528 10.8a.75.75 0 0 0-1.056 1.065L2.528 10.8Zm16.088-3.408a.75.75 0 1 0 1.277-.786l-1.277.786ZM12.079 2.25c-5.047 0-9.15 4.061-9.15 9.083h1.5c0-4.182 3.42-7.583 7.65-7.583v-1.5Zm-9.15 9.083V13h1.5v-1.667h-1.5Zm1.28 2.2l1.679-1.667L4.83 10.8l-1.68 1.667l1.057 1.064Zm0-1.065L2.528 10.8l-1.057 1.065l1.68 1.666l1.056-1.064Zm15.684-5.86A9.158 9.158 0 0 0 12.08 2.25v1.5a7.658 7.658 0 0 1 6.537 3.643l1.277-.786Z" />