fix: check connection

This commit is contained in:
Andras Bacsai 2023-10-09 15:08:28 +02:00
parent b650f3f754
commit ebd8e2ce40
5 changed files with 21 additions and 31 deletions

View File

@ -21,11 +21,13 @@ class Heading extends Component
public function check_status() public function check_status()
{ {
dispatch(new ContainerStatusJob($this->application->destination->server)); if ($this->application->destination->server->isFunctional()) {
$this->application->refresh(); dispatch(new ContainerStatusJob($this->application->destination->server));
$this->application->previews->each(function ($preview) { $this->application->refresh();
$preview->refresh(); $this->application->previews->each(function ($preview) {
}); $preview->refresh();
});
}
} }
public function force_deploy_without_cache() public function force_deploy_without_cache()

View File

@ -31,7 +31,9 @@ class Danger extends Component
$destination = $this->resource->destination->getMorphClass()::where('id', $this->resource->destination->id)->first(); $destination = $this->resource->destination->getMorphClass()::where('id', $this->resource->destination->id)->first();
$server = $destination->server; $server = $destination->server;
} }
instant_remote_process(["docker rm -f {$this->resource->uuid}"], $server); if ($this->resource->destination->server->isFunctional()) {
instant_remote_process(["docker rm -f {$this->resource->uuid}"], $server);
}
} }
$this->resource->delete(); $this->resource->delete();
return redirect()->route('project.resources', [ return redirect()->route('project.resources', [

View File

@ -15,7 +15,7 @@ class Show extends Component
{ {
$this->parameters = get_route_parameters(); $this->parameters = get_route_parameters();
try { try {
$this->server = Server::ownedByCurrentTeam(['name', 'proxy'])->whereUuid(request()->server_uuid)->first(); $this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
if (is_null($this->server)) { if (is_null($this->server)) {
return redirect()->route('server.all'); return redirect()->route('server.all');
} }

View File

@ -32,34 +32,18 @@ class ShowPrivateKey extends Component
} }
} }
public function checkConnection($install = false) public function checkConnection()
{ {
try { try {
$uptime = $this->server->validateConnection(); $uptime = $this->server->validateConnection();
if ($uptime) { if ($uptime) {
$install && $this->emit('success', 'Server is reachable.'); $this->emit('success', 'Server is reachable.');
} else { } else {
$install && $this->emit('error', 'Server is not reachable. Please check your connection and private key configuration.'); $this->emit('error', 'Server is not reachable. Please check your connection and private key configuration.');
return;
}
$dockerInstalled = $this->server->validateDockerEngine();
if ($dockerInstalled) {
$install && $this->emit('success', 'Docker Engine is installed.<br> Checking version.');
} else {
$install && $this->installDocker();
return;
}
$dockerVersion = $this->server->validateDockerEngineVersion();
if ($dockerVersion) {
$install && $this->emit('success', 'Docker Engine version is 23+.');
} else {
$install && $this->installDocker();
return; return;
} }
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} finally {
$this->emit('proxyStatusUpdated');
} }
} }

View File

@ -33,11 +33,13 @@ class Application extends BaseModel
}); });
static::deleting(function ($application) { static::deleting(function ($application) {
// Stop Container // Stop Container
instant_remote_process( if ($application->destination->server->isFunctional()) {
["docker rm -f {$application->uuid}"], instant_remote_process(
$application->destination->server, ["docker rm -f {$application->uuid}"],
false $application->destination->server,
); false
);
}
$application->settings()->delete(); $application->settings()->delete();
$storages = $application->persistentStorages()->get(); $storages = $application->persistentStorages()->get();
foreach ($storages as $storage) { foreach ($storages as $storage) {