From b197ae623723d4e7f8d3807e22f1331b6496f554 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 13 Jan 2025 11:03:54 +0100 Subject: [PATCH 1/5] fix --- app/Jobs/ApplicationDeploymentJob.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index ffdf771d8..49660f4a8 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -166,8 +166,6 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue private bool $preserveRepository = false; - public $tries = 1; - public function tags() { // Do not remove this one, it needs to properly identify which worker is running the job From c4a75f4b87e8aa5a765fb37965d26a788d7a1c1e Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 13 Jan 2025 11:06:10 +0100 Subject: [PATCH 2/5] fix: service update statsu --- app/Livewire/Project/Service/Configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Livewire/Project/Service/Configuration.php b/app/Livewire/Project/Service/Configuration.php index 4a5e8627f..d1744b178 100644 --- a/app/Livewire/Project/Service/Configuration.php +++ b/app/Livewire/Project/Service/Configuration.php @@ -99,7 +99,7 @@ class Configuration extends Component $this->service->databases->each(function ($database) { $database->refresh(); }); - $this->dispatch('$refresh'); + $this->dispatch('refresh'); } catch (\Exception $e) { return handleError($e, $this); } From dd2d306abc0aa8b20ebcca56d420b4bb3a4d7465 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 13 Jan 2025 12:03:03 +0100 Subject: [PATCH 3/5] feat: force deployment of services fix: added advanced ui dropdown to services --- app/Actions/CoolifyTask/RunRemoteProcess.php | 15 ++--- app/Livewire/ActivityMonitor.php | 14 ----- app/Livewire/Project/Service/Navbar.php | 44 ++++++++++---- app/View/Components/services/advanced.php | 26 ++++++++ .../components/services/advanced.blade.php | 48 +++++++++++++++ .../livewire/project/service/navbar.blade.php | 59 ++++++++----------- 6 files changed, 135 insertions(+), 71 deletions(-) create mode 100644 app/View/Components/services/advanced.php create mode 100644 resources/views/components/services/advanced.blade.php diff --git a/app/Actions/CoolifyTask/RunRemoteProcess.php b/app/Actions/CoolifyTask/RunRemoteProcess.php index 981b81378..926d30fe6 100644 --- a/app/Actions/CoolifyTask/RunRemoteProcess.php +++ b/app/Actions/CoolifyTask/RunRemoteProcess.php @@ -91,16 +91,9 @@ class RunRemoteProcess } else { if ($processResult->exitCode() == 0) { $status = ProcessStatus::FINISHED; - } - if ($processResult->exitCode() != 0 && ! $this->ignore_errors) { + } else { $status = ProcessStatus::ERROR; } - // if (($processResult->exitCode() == 0 && $this->is_finished) || $this->activity->properties->get('status') === ProcessStatus::FINISHED->value) { - // $status = ProcessStatus::FINISHED; - // } - // if ($processResult->exitCode() != 0 && !$this->ignore_errors) { - // $status = ProcessStatus::ERROR; - // } } $this->activity->properties = $this->activity->properties->merge([ @@ -110,9 +103,6 @@ class RunRemoteProcess 'status' => $status->value, ]); $this->activity->save(); - if ($processResult->exitCode() != 0 && ! $this->ignore_errors) { - throw new \RuntimeException($processResult->errorOutput(), $processResult->exitCode()); - } if ($this->call_event_on_finish) { try { if ($this->call_event_data) { @@ -128,6 +118,9 @@ class RunRemoteProcess Log::error('Error calling event: '.$e->getMessage()); } } + if ($processResult->exitCode() != 0 && ! $this->ignore_errors) { + throw new \RuntimeException($processResult->errorOutput(), $processResult->exitCode()); + } return $processResult; } diff --git a/app/Livewire/ActivityMonitor.php b/app/Livewire/ActivityMonitor.php index 2e36f34ee..024f53c3d 100644 --- a/app/Livewire/ActivityMonitor.php +++ b/app/Livewire/ActivityMonitor.php @@ -42,14 +42,8 @@ class ActivityMonitor extends Component public function polling() { $this->hydrateActivity(); - // $this->setStatus(ProcessStatus::IN_PROGRESS); $exit_code = data_get($this->activity, 'properties.exitCode'); if ($exit_code !== null) { - // if ($exit_code === 0) { - // // $this->setStatus(ProcessStatus::FINISHED); - // } else { - // // $this->setStatus(ProcessStatus::ERROR); - // } $this->isPollingActive = false; if ($exit_code === 0) { if ($this->eventToDispatch !== null) { @@ -70,12 +64,4 @@ class ActivityMonitor extends Component } } } - - // protected function setStatus($status) - // { - // $this->activity->properties = $this->activity->properties->merge([ - // 'status' => $status, - // ]); - // $this->activity->save(); - // } } diff --git a/app/Livewire/Project/Service/Navbar.php b/app/Livewire/Project/Service/Navbar.php index 22fc1c0d6..915fb54c6 100644 --- a/app/Livewire/Project/Service/Navbar.php +++ b/app/Livewire/Project/Service/Navbar.php @@ -5,6 +5,7 @@ namespace App\Livewire\Project\Service; use App\Actions\Service\StartService; use App\Actions\Service\StopService; use App\Actions\Shared\PullImage; +use App\Enums\ProcessStatus; use App\Events\ServiceStatusChanged; use App\Models\Service; use Illuminate\Support\Facades\Auth; @@ -68,11 +69,9 @@ class Navbar extends Component public function checkDeployments() { try { - // TODO: This is a temporary solution. We need to refactor this. - // We need to delete null bytes somehow. $activity = Activity::where('properties->type_uuid', $this->service->uuid)->latest()->first(); $status = data_get($activity, 'properties.status'); - if ($status === 'queued' || $status === 'in_progress') { + if ($status === ProcessStatus::QUEUED->value || $status === ProcessStatus::IN_PROGRESS->value) { $this->isDeploymentProgress = true; } else { $this->isDeploymentProgress = false; @@ -80,25 +79,46 @@ class Navbar extends Component } catch (\Throwable) { $this->isDeploymentProgress = false; } + + return $this->isDeploymentProgress; } public function start() { - $this->checkDeployments(); - if ($this->isDeploymentProgress) { - $this->dispatch('error', 'There is a deployment in progress.'); - - return; - } $this->service->parse(); $activity = StartService::run($this->service); $this->dispatch('activityMonitor', $activity->id); } - public function stop() + public function forceDeploy() { - StopService::run($this->service, false, $this->docker_cleanup); - ServiceStatusChanged::dispatch(); + try { + $activities = Activity::where('properties->type_uuid', $this->service->uuid)->where('properties->status', ProcessStatus::IN_PROGRESS->value)->orWhere('properties->status', ProcessStatus::QUEUED->value)->get(); + foreach ($activities as $activity) { + $activity->properties->status = ProcessStatus::ERROR->value; + $activity->save(); + } + $this->service->parse(); + $activity = StartService::run($this->service); + $this->dispatch('activityMonitor', $activity->id); + } catch (\Exception $e) { + $this->dispatch('error', $e->getMessage()); + } + } + + public function stop($cleanupContainers = false) + { + try { + StopService::run($this->service, false, $this->docker_cleanup); + ServiceStatusChanged::dispatch(); + if ($cleanupContainers) { + $this->dispatch('success', 'Containers cleaned up.'); + } else { + $this->dispatch('success', 'Service stopped.'); + } + } catch (\Exception $e) { + $this->dispatch('error', $e->getMessage()); + } } public function restart() diff --git a/app/View/Components/services/advanced.php b/app/View/Components/services/advanced.php new file mode 100644 index 000000000..7e68c6dda --- /dev/null +++ b/app/View/Components/services/advanced.php @@ -0,0 +1,26 @@ + + + Advanced + + @if (str($service->status)->contains('running')) + + @elseif (str($service->status)->contains('degraded')) + + @else + + + @endif + diff --git a/resources/views/livewire/project/service/navbar.blade.php b/resources/views/livewire/project/service/navbar.blade.php index b90d9e81d..405a6957e 100644 --- a/resources/views/livewire/project/service/navbar.blade.php +++ b/resources/views/livewire/project/service/navbar.blade.php @@ -8,7 +8,7 @@

{{ $title }}

-