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: enhance error handling in initialization and cleanup process

Andras Bacsaif1d80d677662
diff --git a/app/Console/Commands/CleanupStuckedResources.php b/app/Console/Commands/CleanupStuckedResources.php
index 0b13462efb..165a3ae219 100644
--- a/app/Console/Commands/CleanupStuckedResources.php
+++ b/app/Console/Commands/CleanupStuckedResources.php
@@ -222,9 +222,14 @@ class CleanupStuckedResources extends Command
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 @@ class CleanupStuckedResources extends Command
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 @@ class CleanupStuckedResources extends Command
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 4bc818f0ac..975a3c006e 100644
--- a/app/Console/Commands/Init.php
+++ b/app/Console/Commands/Init.php
@@ -86,6 +86,7 @@ class Init extends Command
$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', [