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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat: send new docker cleanup notifications
peaklabs-devf36043943c24
diff --git a/app/Jobs/DockerCleanupJob.php b/app/Jobs/DockerCleanupJob.phpindex 80542e03bf..103c137b9f 100644--- a/app/Jobs/DockerCleanupJob.php+++ b/app/Jobs/DockerCleanupJob.php@@ -4,7 +4,8 @@ namespace App\Jobs;use App\Actions\Server\CleanupDocker;use App\Models\Server;-use App\Notifications\Server\DockerCleanup;+use App\Notifications\Server\DockerCleanupFailed;+use App\Notifications\Server\DockerCleanupSuccess;use Illuminate\Bus\Queueable;use Illuminate\Contracts\Queue\ShouldBeEncrypted;use Illuminate\Contracts\Queue\ShouldQueue;@@ -12,7 +13,6 @@ use Illuminate\Foundation\Bus\Dispatchable;use Illuminate\Queue\InteractsWithQueue;use Illuminate\Queue\Middleware\WithoutOverlapping;use Illuminate\Queue\SerializesModels;-use Illuminate\Support\Facades\Log;class DockerCleanupJob implements ShouldBeEncrypted, ShouldQueue{@@ -38,35 +38,36 @@ class DockerCleanupJob implements ShouldBeEncrypted, ShouldQueuereturn;}+ $this->usageBefore = $this->server->getDiskUsage();+if ($this->manualCleanup || $this->server->settings->force_docker_cleanup) {- Log::info('DockerCleanupJob '.($this->manualCleanup ? 'manual' : 'force').' cleanup on '.$this->server->name);CleanupDocker::run(server: $this->server);+ $usageAfter = $this->server->getDiskUsage();+ $this->server->team?->notify(new DockerCleanupSuccess($this->server, ($this->manualCleanup ? 'Manual' : 'Forced').' Docker cleanup job executed successfully. Disk usage before: '.$this->usageBefore.'%, Disk usage after: '.$usageAfter.'%.'));return;}- $this->usageBefore = $this->server->getDiskUsage();if (str($this->usageBefore)->isEmpty() || $this->usageBefore === null || $this->usageBefore === 0) {- Log::info('DockerCleanupJob force cleanup on '.$this->server->name);CleanupDocker::run(server: $this->server);-- return;+ $this->server->team?->notify(new DockerCleanupSuccess($this->server, 'Docker cleanup job executed successfully, but no disk usage could be determined.'));}+if ($this->usageBefore >= $this->server->settings->docker_cleanup_threshold) {CleanupDocker::run(server: $this->server);$usageAfter = $this->server->getDiskUsage();- if ($usageAfter < $this->usageBefore) {- $this->server->team?->notify(new DockerCleanup($this->server, 'Saved '.($this->usageBefore - $usageAfter).'% disk space.'));- Log::info('DockerCleanupJob done: Saved '.($this->usageBefore - $usageAfter).'% disk space on '.$this->server->name);+ $diskSaved = $this->usageBefore - $usageAfter;++ if ($diskSaved > 0) {+ $this->server->team?->notify(new DockerCleanupSuccess($this->server, 'Saved '.$diskSaved.'% disk space. Disk usage before: '.$this->usageBefore.'%, Disk usage after: '.$usageAfter.'%.'));} else {- Log::info('DockerCleanupJob failed to save disk space on '.$this->server->name);+ $this->server->team?->notify(new DockerCleanupSuccess($this->server, 'Docker cleanup job executed successfully, but no disk space was saved. Disk usage before: '.$this->usageBefore.'%, Disk usage after: '.$usageAfter.'%.'));}} else {- Log::info('No need to clean up '.$this->server->name);+ $this->server->team?->notify(new DockerCleanupSuccess($this->server, 'No cleanup needed for '.$this->server->name));}} catch (\Throwable $e) {- CleanupDocker::run(server: $this->server);- Log::error('DockerCleanupJob failed: '.$e->getMessage());+ $this->server->team?->notify(new DockerCleanupFailed($this->server, 'Docker cleanup job failed with the following error: '.$e->getMessage()));throw $e;}}