diff --git a/app/Livewire/Server/Form.php b/app/Livewire/Server/Form.php
index 239fa86bd..75e65c319 100644
--- a/app/Livewire/Server/Form.php
+++ b/app/Livewire/Server/Form.php
@@ -88,7 +88,7 @@ class Form extends Component
}
public function validateServer($install = true)
{
- $this->dispatch('validateServer', $install);
+ $this->dispatch('init', $install);
}
public function submit()
diff --git a/app/Livewire/Server/ValidateAndInstall.php b/app/Livewire/Server/ValidateAndInstall.php
index b5c46fa32..bc2af95d2 100644
--- a/app/Livewire/Server/ValidateAndInstall.php
+++ b/app/Livewire/Server/ValidateAndInstall.php
@@ -2,6 +2,7 @@
namespace App\Livewire\Server;
+use App\Actions\Proxy\CheckProxy;
use App\Actions\Proxy\StartProxy;
use App\Models\Server;
use Livewire\Component;
@@ -10,7 +11,7 @@ class ValidateAndInstall extends Component
{
public Server $server;
public int $number_of_tries = 0;
- public int $max_tries = 1;
+ public int $max_tries = 2;
public bool $install = true;
public $uptime = null;
public $supported_os_type = null;
@@ -21,7 +22,15 @@ class ValidateAndInstall extends Component
public $error = null;
public bool $ask = false;
- protected $listeners = ['validateServer' => 'init', 'validateDockerEngine', 'validateServerNow' => 'validateServer'];
+ protected $listeners = [
+ 'init',
+ 'validateConnection',
+ 'validateOS',
+ 'validateDockerEngine',
+ 'validateDockerVersion',
+ 'startProxy',
+ 'refresh' => '$refresh',
+ ];
public function init(bool $install = true)
{
@@ -35,31 +44,29 @@ class ValidateAndInstall extends Component
$this->error = null;
$this->number_of_tries = 0;
if (!$this->ask) {
- $this->dispatch('validateServerNow');
+ $this->dispatch('validateConnection');
}
}
- public function startValidatingAfterAsking() {
+ public function startValidatingAfterAsking()
+ {
$this->ask = false;
$this->init();
}
- public function validateServer()
+ public function startProxy()
{
try {
- $this->validateConnection();
- $this->validateOS();
- $this->validateDockerEngine();
-
- if ($this->server->isSwarm()) {
- $swarmInstalled = $this->server->validateDockerSwarm();
- if ($swarmInstalled) {
- $this->dispatch('success', 'Docker Swarm is initiated.');
+ $shouldStart = CheckProxy::run($this->server);
+ if ($shouldStart) {
+ $proxy = StartProxy::run($this->server, false);
+ if ($proxy === 'OK') {
+ $this->proxy_started = true;
+ } else {
+ throw new \Exception("Proxy could not be started.");
}
} else {
- $proxy = StartProxy::run($this->server);
- if ($proxy) {
- $this->proxy_started = true;
- }
+ $this->proxy_started = true;
}
+
} catch (\Throwable $e) {
return handleError($e, $this);
}
@@ -71,6 +78,7 @@ class ValidateAndInstall extends Component
$this->error = 'Server is not reachable. Please validate your configuration and connection.
Check this documentation for further help.';
return;
}
+ $this->dispatch('validateOS');
}
public function validateOS()
{
@@ -79,6 +87,7 @@ class ValidateAndInstall extends Component
$this->error = 'Server OS type is not supported. Please install Docker manually before continuing: documentation.';
return;
}
+ $this->dispatch('validateDockerEngine');
}
public function validateDockerEngine()
{
@@ -90,29 +99,39 @@ class ValidateAndInstall extends Component
$this->error = 'Docker Engine could not be installed. Please install Docker manually before continuing: documentation.';
return;
} else {
- $activity = $this->server->installDocker();
- $this->number_of_tries++;
- $this->dispatch('newActivityMonitor', $activity->id, 'validateDockerEngine');
+ if ($this->number_of_tries == 0 ) {
+ $activity = $this->server->installDocker();
+ $this->number_of_tries++;
+ $this->dispatch('newActivityMonitor', $activity->id, 'init');
+ }
return;
}
} else {
$this->error = 'Docker Engine is not installed. Please install Docker manually before continuing: documentation.';
return;
}
- } else {
- $this->validateDockerVersion();
}
+ $this->dispatch('validateDockerVersion');
}
public function validateDockerVersion()
{
- $this->docker_version = $this->server->validateDockerEngineVersion();
- if ($this->docker_version) {
- $this->dispatch('serverInstalled');
- $this->dispatch('success', 'Server validated successfully.');
+ if ($this->server->isSwarm()) {
+ $swarmInstalled = $this->server->validateDockerSwarm();
+ if ($swarmInstalled) {
+ $this->dispatch('success', 'Docker Swarm is initiated.');
+ }
} else {
- $this->error = 'Docker Engine version is not 22+. Please install Docker manually before continuing: documentation.';
- return;
+ $this->docker_version = $this->server->validateDockerEngineVersion();
+ if ($this->docker_version) {
+ $this->dispatch('serverInstalled');
+ $this->dispatch('success', 'Server validated successfully.');
+ } else {
+ $this->error = 'Docker Engine version is not 22+. Please install Docker manually before continuing: documentation.';
+ return;
+ }
}
+
+ $this->dispatch('startProxy');
}
public function render()
{
diff --git a/app/Models/Server.php b/app/Models/Server.php
index 76ed8c8a9..27f0432a3 100644
--- a/app/Models/Server.php
+++ b/app/Models/Server.php
@@ -398,10 +398,10 @@ class Server extends BaseModel
}
});
if ($supported->count() === 1) {
- ray('supported');
+ // ray('supported');
return str($supported->first());
} else {
- ray('not supported');
+ // ray('not supported');
return false;
}
}
@@ -468,6 +468,16 @@ class Server extends BaseModel
}
return false;
}
+ try {
+ $dockerRunning = instant_remote_process(["docker version"], $this);
+ } catch (\Throwable $e) {
+ $this->settings->is_usable = false;
+ $this->settings->save();
+ if ($throwError) {
+ throw new \Exception('Server is not usable. Docker Engine is not running.');
+ }
+ return false;
+ }
$this->settings->is_usable = true;
$this->settings->save();
$this->validateCoolifyNetwork(isSwarm: false, isBuildServer: $this->settings->is_build_server);
diff --git a/resources/views/livewire/server/validate-and-install.blade.php b/resources/views/livewire/server/validate-and-install.blade.php
index 35d5ab06a..8d50c3608 100644
--- a/resources/views/livewire/server/validate-and-install.blade.php
+++ b/resources/views/livewire/server/validate-and-install.blade.php
@@ -3,7 +3,7 @@
This will revalidate the server, install / update Docker Engine, Docker Compose and all related
configuration. It will also restart Docker Engine, so your running containers will be unreachable
for the time being.
-
{!! $error !!}
@endisset