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: application view

Andras Bacsaie052047b0469
diff --git a/app/Http/Livewire/DeployApplication.php b/app/Http/Livewire/DeployApplication.php
index 82fccd9ad8..14401a1fc3 100644
--- a/app/Http/Livewire/DeployApplication.php
+++ b/app/Http/Livewire/DeployApplication.php
@@ -21,15 +21,19 @@ class DeployApplication extends Component
{
public string $application_uuid;
public $activity;
+ public $status;
+ public Application $application;
+ public $destination;
protected string $deployment_uuid;
protected array $command = [];
- protected Application $application;
- protected $destination;
protected $source;
- public function mount($application_uuid) {
+ public function mount($application_uuid)
+ {
$this->application_uuid = $application_uuid;
+ $this->application = Application::where('uuid', $this->application_uuid)->first();
+ $this->destination = $this->application->destination->getMorphClass()::where('id', $this->application->destination->id)->first();
}
public function render()
{
@@ -152,7 +156,6 @@ class DeployApplication extends Component
public function deploy()
{
$coolify_instance_settings = CoolifyInstanceSettings::find(1);
- $this->application = Application::where('uuid', $this->application_uuid)->first();
$this->destination = $this->application->destination->getMorphClass()::where('id', $this->application->destination->id)->first();
$this->source = $this->application->source->getMorphClass()::where('id', $this->application->source->id)->first();
@@ -244,26 +247,24 @@ class DeployApplication extends Component
public function stop()
{
- $application = Application::where('uuid', $this->application_uuid)->first();
- $destination = $application->destination->getMorphClass()::where('id', $application->destination->id)->first();
- $command[] = "docker rm -f {$application->uuid} >/dev/null 2>&1";
- remoteProcess($command, $destination->server, null, $application);
+ $output = runRemoteCommandSync($this->destination->server, ["docker rm -f {$this->application_uuid} >/dev/null 2>&1"]);
+ $this->application->status = 'exited';
+ $this->application->save();
+ // $this->application->refresh();
+ }
+ public function pollingStatus()
+ {
+ $this->application->refresh();
}
- public function checkStatus() {
- $application = Application::where('uuid', $this->application_uuid)->first();
- $destination = $application->destination->getMorphClass()::where('id', $application->destination->id)->first();
- $private_key_location = savePrivateKey($destination->server);
- $ssh_command = generateSshCommand($private_key_location, $destination->server->ip, $destination->server->user, $destination->server->port, "docker ps -a --format '{{.State}}' --filter 'name={$application->uuid}'");
- $process = Process::run($ssh_command);
- $output = trim($process->output());
+ public function checkStatus()
+ {
+ $output = runRemoteCommandSync($this->destination->server, ["docker ps -a --format '{{.State}}' --filter 'name={$this->application->uuid}'"]);
if ($output == '') {
- $application->status = 'exited';
- $application->save();
+ $this->application->status = 'exited';
+ $this->application->save();
} else {
- $application->status = $output;
- $application->save();
+ $this->application->status = $output;
+ $this->application->save();
}
- // ContainerStatusJob::dispatch();
}
-
}
diff --git a/resources/views/livewire/deploy-application.blade.php b/resources/views/livewire/deploy-application.blade.php
index 78ae2df99e..21ba7248e5 100644
--- a/resources/views/livewire/deploy-application.blade.php
+++ b/resources/views/livewire/deploy-application.blade.php
@@ -2,4 +2,5 @@
<button wire:click='deploy'>Deploy</button>
<button wire:click='stop'>Stop</button>
<button wire:click='checkStatus'>CheckStatus</button>
+ <span wire:poll='pollingStatus'>status: {{ $application->status }}</span>
</div>
diff --git a/resources/views/project/application.blade.php b/resources/views/project/application.blade.php
index 4a87abef26..716fb3765e 100644
--- a/resources/views/project/application.blade.php
+++ b/resources/views/project/application.blade.php
@@ -1,15 +1,14 @@
<x-layout>
<h1>Application</h1>
<p>Name: {{ $application->name }}</p>
- <p>Application UUID: {{ $application->uuid }}</p>
- <p>Status: {{ $application->status }}</p>
<livewire:deploy-application :application_uuid="$application->uuid" />
<div>
- <h1>Deployments</h1>
+ <h2>Deployments</h2>
@foreach ($deployments as $deployment)
<p>
<a href="{{ url()->current() }}/deployment/{{ data_get($deployment->properties, 'deployment_uuid') }}">
{{ data_get($deployment->properties, 'deployment_uuid') }}</a>
+ {{ data_get($deployment->properties, 'status') }}
</p>
@endforeach
</div>