From f1d80d677662f68680191effd722fe32fe152c7d Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Mon, 10 Nov 2025 15:29:26 +0100 Subject: [PATCH] fix: enhance error handling in initialization and cleanup process --- app/Console/Commands/CleanupStuckedResources.php | 15 ++++++++++----- app/Console/Commands/Init.php | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/Console/Commands/CleanupStuckedResources.php b/app/Console/Commands/CleanupStuckedResources.php index 0b13462ef..165a3ae21 100644 --- a/app/Console/Commands/CleanupStuckedResources.php +++ b/app/Console/Commands/CleanupStuckedResources.php @@ -222,9 +222,14 @@ private function cleanup_stucked_resources() try { $scheduled_backups = ScheduledDatabaseBackup::all(); foreach ($scheduled_backups as $scheduled_backup) { - if (! $scheduled_backup->server()) { - echo "Deleting stuck scheduledbackup: {$scheduled_backup->name}\n"; - $scheduled_backup->delete(); + try { + $server = $scheduled_backup->server(); + if (! $server) { + echo "Deleting stuck scheduledbackup: {$scheduled_backup->name}\n"; + $scheduled_backup->delete(); + } + } catch (\Throwable $e) { + echo "Error checking server for scheduledbackup {$scheduled_backup->id}: {$e->getMessage()}\n"; } } } catch (\Throwable $e) { @@ -416,7 +421,7 @@ private function cleanup_stucked_resources() foreach ($serviceApplications as $service) { if (! data_get($service, 'service')) { echo 'ServiceApplication without service: '.$service->name.'\n'; - DeleteResourceJob::dispatch($service); + $service->forceDelete(); continue; } @@ -429,7 +434,7 @@ private function cleanup_stucked_resources() foreach ($serviceDatabases as $service) { if (! data_get($service, 'service')) { echo 'ServiceDatabase without service: '.$service->name.'\n'; - DeleteResourceJob::dispatch($service); + $service->forceDelete(); continue; } diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php index 4bc818f0a..975a3c006 100644 --- a/app/Console/Commands/Init.php +++ b/app/Console/Commands/Init.php @@ -86,6 +86,7 @@ public function handle() $this->call('cleanup:stucked-resources'); } catch (\Throwable $e) { echo "Error in cleanup:stucked-resources command: {$e->getMessage()}\n"; + echo "Continuing with initialization - cleanup errors will not prevent Coolify from starting\n"; } try { $updatedCount = ApplicationDeploymentQueue::whereIn('status', [