fix: application view
This commit is contained in:
parent
47d3ac3ef5
commit
e052047b04
@ -21,15 +21,19 @@ class DeployApplication extends Component
|
|||||||
{
|
{
|
||||||
public string $application_uuid;
|
public string $application_uuid;
|
||||||
public $activity;
|
public $activity;
|
||||||
|
public $status;
|
||||||
|
public Application $application;
|
||||||
|
public $destination;
|
||||||
|
|
||||||
protected string $deployment_uuid;
|
protected string $deployment_uuid;
|
||||||
protected array $command = [];
|
protected array $command = [];
|
||||||
protected Application $application;
|
|
||||||
protected $destination;
|
|
||||||
protected $source;
|
protected $source;
|
||||||
|
|
||||||
public function mount($application_uuid) {
|
public function mount($application_uuid)
|
||||||
|
{
|
||||||
$this->application_uuid = $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()
|
public function render()
|
||||||
{
|
{
|
||||||
@ -152,7 +156,6 @@ private function generate_jwt_token_for_github()
|
|||||||
public function deploy()
|
public function deploy()
|
||||||
{
|
{
|
||||||
$coolify_instance_settings = CoolifyInstanceSettings::find(1);
|
$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->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();
|
$this->source = $this->application->source->getMorphClass()::where('id', $this->application->source->id)->first();
|
||||||
|
|
||||||
@ -244,26 +247,24 @@ public function deploy()
|
|||||||
|
|
||||||
public function stop()
|
public function stop()
|
||||||
{
|
{
|
||||||
$application = Application::where('uuid', $this->application_uuid)->first();
|
$output = runRemoteCommandSync($this->destination->server, ["docker rm -f {$this->application_uuid} >/dev/null 2>&1"]);
|
||||||
$destination = $application->destination->getMorphClass()::where('id', $application->destination->id)->first();
|
$this->application->status = 'exited';
|
||||||
$command[] = "docker rm -f {$application->uuid} >/dev/null 2>&1";
|
$this->application->save();
|
||||||
remoteProcess($command, $destination->server, null, $application);
|
// $this->application->refresh();
|
||||||
}
|
}
|
||||||
public function checkStatus() {
|
public function pollingStatus()
|
||||||
$application = Application::where('uuid', $this->application_uuid)->first();
|
{
|
||||||
$destination = $application->destination->getMorphClass()::where('id', $application->destination->id)->first();
|
$this->application->refresh();
|
||||||
$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}'");
|
public function checkStatus()
|
||||||
$process = Process::run($ssh_command);
|
{
|
||||||
$output = trim($process->output());
|
$output = runRemoteCommandSync($this->destination->server, ["docker ps -a --format '{{.State}}' --filter 'name={$this->application->uuid}'"]);
|
||||||
if ($output == '') {
|
if ($output == '') {
|
||||||
$application->status = 'exited';
|
$this->application->status = 'exited';
|
||||||
$application->save();
|
$this->application->save();
|
||||||
} else {
|
} else {
|
||||||
$application->status = $output;
|
$this->application->status = $output;
|
||||||
$application->save();
|
$this->application->save();
|
||||||
}
|
}
|
||||||
// ContainerStatusJob::dispatch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,4 +2,5 @@
|
|||||||
<button wire:click='deploy'>Deploy</button>
|
<button wire:click='deploy'>Deploy</button>
|
||||||
<button wire:click='stop'>Stop</button>
|
<button wire:click='stop'>Stop</button>
|
||||||
<button wire:click='checkStatus'>CheckStatus</button>
|
<button wire:click='checkStatus'>CheckStatus</button>
|
||||||
|
<span wire:poll='pollingStatus'>status: {{ $application->status }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
<x-layout>
|
<x-layout>
|
||||||
<h1>Application</h1>
|
<h1>Application</h1>
|
||||||
<p>Name: {{ $application->name }}</p>
|
<p>Name: {{ $application->name }}</p>
|
||||||
<p>Application UUID: {{ $application->uuid }}</p>
|
|
||||||
<p>Status: {{ $application->status }}</p>
|
|
||||||
<livewire:deploy-application :application_uuid="$application->uuid" />
|
<livewire:deploy-application :application_uuid="$application->uuid" />
|
||||||
<div>
|
<div>
|
||||||
<h1>Deployments</h1>
|
<h2>Deployments</h2>
|
||||||
@foreach ($deployments as $deployment)
|
@foreach ($deployments as $deployment)
|
||||||
<p>
|
<p>
|
||||||
<a href="{{ url()->current() }}/deployment/{{ data_get($deployment->properties, 'deployment_uuid') }}">
|
<a href="{{ url()->current() }}/deployment/{{ data_get($deployment->properties, 'deployment_uuid') }}">
|
||||||
{{ data_get($deployment->properties, 'deployment_uuid') }}</a>
|
{{ data_get($deployment->properties, 'deployment_uuid') }}</a>
|
||||||
|
{{ data_get($deployment->properties, 'status') }}
|
||||||
</p>
|
</p>
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user