wip
This commit is contained in:
@@ -23,7 +23,7 @@ class StartService
|
||||
}
|
||||
$commands[] = "docker compose pull";
|
||||
$commands[] = "docker compose up -d";
|
||||
$commands[] = "docker network connect $service->uuid coolify-proxy";
|
||||
$commands[] = "docker network connect $service->uuid coolify-proxy 2>/dev/null || true";
|
||||
$activity = remote_process($commands, $service->server);
|
||||
return $activity;
|
||||
}
|
||||
|
||||
25
app/Actions/Service/StopService.php
Normal file
25
app/Actions/Service/StopService.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Service;
|
||||
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
use App\Models\Service;
|
||||
|
||||
class StopService
|
||||
{
|
||||
use AsAction;
|
||||
public function handle(Service $service)
|
||||
{
|
||||
$applications = $service->applications()->get();
|
||||
foreach ($applications as $application) {
|
||||
instant_remote_process(["docker rm -f {$application->name}-{$service->uuid}"], $service->server);
|
||||
$application->update(['status' => 'exited']);
|
||||
}
|
||||
$dbs = $service->databases()->get();
|
||||
foreach ($dbs as $db) {
|
||||
instant_remote_process(["docker rm -f {$db->name}-{$service->uuid}"], $service->server);
|
||||
$db->update(['status' => 'exited']);
|
||||
}
|
||||
instant_remote_process(["docker network disconnect {$service->uuid} coolify-proxy 2>/dev/null"], $service->server);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Livewire\Project\Service;
|
||||
|
||||
use App\Actions\Service\StartService;
|
||||
use App\Actions\Service\StopService;
|
||||
use App\Jobs\ContainerStatusJob;
|
||||
use App\Models\Service;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -15,7 +16,7 @@ class Index extends Component
|
||||
public array $parameters;
|
||||
public array $query;
|
||||
public Collection $services;
|
||||
|
||||
protected $listeners = ['serviceStatusUpdated'];
|
||||
protected $rules = [
|
||||
'services.*.fqdn' => 'nullable',
|
||||
];
|
||||
@@ -39,11 +40,14 @@ class Index extends Component
|
||||
{
|
||||
return view('livewire.project.service.index')->layout('layouts.app');
|
||||
}
|
||||
public function serviceStatusUpdated() {
|
||||
ray('serviceStatusUpdated');
|
||||
$this->check_status();
|
||||
}
|
||||
public function check_status()
|
||||
{
|
||||
dispatch_sync(new ContainerStatusJob($this->service->server));
|
||||
$this->service->refresh();
|
||||
|
||||
}
|
||||
public function submit()
|
||||
{
|
||||
@@ -76,4 +80,8 @@ class Index extends Component
|
||||
$activity = StartService::run($this->service);
|
||||
$this->emit('newMonitorActivity', $activity->id);
|
||||
}
|
||||
public function stop() {
|
||||
StopService::run($this->service);
|
||||
$this->service->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
16
app/Http/Livewire/Project/Service/Modal.php
Normal file
16
app/Http/Livewire/Project/Service/Modal.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Project\Service;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class Modal extends Component
|
||||
{
|
||||
public function serviceStatusUpdated() {
|
||||
$this->emit('serviceStatusUpdated');
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.project.service.modal');
|
||||
}
|
||||
}
|
||||
@@ -44,9 +44,12 @@ class EnvironmentVariable extends Model
|
||||
);
|
||||
}
|
||||
|
||||
private function get_environment_variables(string $environment_variable): string|null
|
||||
private function get_environment_variables(?string $environment_variable = null): string|null
|
||||
{
|
||||
// $team_id = currentTeam()->id;
|
||||
if (!$environment_variable) {
|
||||
return null;
|
||||
}
|
||||
$environment_variable = trim(decrypt($environment_variable));
|
||||
if (Str::startsWith($environment_variable, '{{') && Str::endsWith($environment_variable, '}}') && Str::contains($environment_variable, 'global.')) {
|
||||
$variable = Str::after($environment_variable, 'global.');
|
||||
|
||||
@@ -16,31 +16,7 @@ class Services extends Component
|
||||
public Service $service,
|
||||
public string $complexStatus = 'exited',
|
||||
) {
|
||||
$foundRunning = false;
|
||||
$isDegraded = false;
|
||||
$applications = $service->applications;
|
||||
$databases = $service->databases;
|
||||
foreach ($applications as $application) {
|
||||
if ($application->status === 'running') {
|
||||
$foundRunning = true;
|
||||
} else {
|
||||
$isDegraded = true;
|
||||
}
|
||||
}
|
||||
foreach ($databases as $database) {
|
||||
if ($database->status === 'running') {
|
||||
$foundRunning = true;
|
||||
} else {
|
||||
$isDegraded = true;
|
||||
}
|
||||
}
|
||||
if ($foundRunning && !$isDegraded) {
|
||||
$this->complexStatus = 'running';
|
||||
} else if ($foundRunning && $isDegraded) {
|
||||
$this->complexStatus = 'degraded';
|
||||
} else if (!$foundRunning && $isDegraded) {
|
||||
$this->complexStatus = 'exited';
|
||||
}
|
||||
$this->complexStatus = serviceStatus($service);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user