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.

Update DockerCleanupJob and version numbers

Andras Bacsai130d1e17569e
diff --git a/app/Jobs/DockerCleanupJob.php b/app/Jobs/DockerCleanupJob.php
index 69c4458010..01f085d93f 100644
--- a/app/Jobs/DockerCleanupJob.php
+++ b/app/Jobs/DockerCleanupJob.php
@@ -4,6 +4,7 @@ namespace App\Jobs;
use App\Actions\Server\CleanupDocker;
use App\Models\Server;
+use App\Notifications\Server\DockerCleanup;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -47,8 +48,9 @@ class DockerCleanupJob implements ShouldQueue, ShouldBeEncrypted
CleanupDocker::run($this->server);
$usageAfter = $this->server->getDiskUsage();
if ($usageAfter < $this->usageBefore) {
- ray('Saved ' . ($this->usageBefore - $usageAfter) . '% disk space on ' . $this->server->name);
- send_internal_notification('DockerCleanupJob done: Saved ' . ($this->usageBefore - $usageAfter) . '% disk space on ' . $this->server->name);
+ $this->server->team?->notify(new DockerCleanup($this->server, 'Saved ' . ($this->usageBefore - $usageAfter) . '% disk space.'));
+ // ray('Saved ' . ($this->usageBefore - $usageAfter) . '% disk space on ' . $this->server->name);
+ // send_internal_notification('DockerCleanupJob done: Saved ' . ($this->usageBefore - $usageAfter) . '% disk space on ' . $this->server->name);
Log::info('DockerCleanupJob done: Saved ' . ($this->usageBefore - $usageAfter) . '% disk space on ' . $this->server->name);
} else {
Log::info('DockerCleanupJob failed to save disk space on ' . $this->server->name);
diff --git a/app/Notifications/Server/DockerCleanup.php b/app/Notifications/Server/DockerCleanup.php
new file mode 100644
index 0000000000..754287fa18
--- /dev/null
+++ b/app/Notifications/Server/DockerCleanup.php
@@ -0,0 +1,63 @@
+<?php
+
+namespace App\Notifications\Server;
+
+use App\Models\Server;
+use Illuminate\Bus\Queueable;
+use App\Notifications\Channels\DiscordChannel;
+use App\Notifications\Channels\TelegramChannel;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Notifications\Notification;
+
+class DockerCleanup extends Notification implements ShouldQueue
+{
+ use Queueable;
+
+ public $tries = 1;
+ public function __construct(public Server $server, public string $message)
+ {
+ }
+
+ public function via(object $notifiable): array
+ {
+ $channels = [];
+ // $isEmailEnabled = isEmailEnabled($notifiable);
+ $isDiscordEnabled = data_get($notifiable, 'discord_enabled');
+ $isTelegramEnabled = data_get($notifiable, 'telegram_enabled');
+
+ if ($isDiscordEnabled) {
+ $channels[] = DiscordChannel::class;
+ }
+ // if ($isEmailEnabled) {
+ // $channels[] = EmailChannel::class;
+ // }
+ if ($isTelegramEnabled) {
+ $channels[] = TelegramChannel::class;
+ }
+ return $channels;
+ }
+
+ // public function toMail(): MailMessage
+ // {
+ // $mail = new MailMessage();
+ // $mail->subject("Coolify: Server ({$this->server->name}) high disk usage detected!");
+ // $mail->view('emails.high-disk-usage', [
+ // 'name' => $this->server->name,
+ // 'disk_usage' => $this->disk_usage,
+ // 'threshold' => $this->cleanup_after_percentage,
+ // ]);
+ // return $mail;
+ // }
+
+ public function toDiscord(): string
+ {
+ $message = "Coolify: Server '{$this->server->name}' cleanup job done!\n\n{$this->message}";
+ return $message;
+ }
+ public function toTelegram(): array
+ {
+ return [
+ "message" => "Coolify: Server '{$this->server->name}' cleanup job done!\n\n{$this->message}"
+ ];
+ }
+}
diff --git a/config/sentry.php b/config/sentry.php
index 1b96a2a02b..438c452463 100644
--- a/config/sentry.php
+++ b/config/sentry.php
@@ -7,7 +7,7 @@ return [
// The release version of your application
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
- 'release' => '4.0.0-beta.231',
+ 'release' => '4.0.0-beta.232',
// When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'),
diff --git a/config/version.php b/config/version.php
index 53d87bbd52..2ff41e4554 100644
--- a/config/version.php
+++ b/config/version.php
@@ -1,3 +1,3 @@
<?php
-return '4.0.0-beta.231';
+return '4.0.0-beta.232';
diff --git a/versions.json b/versions.json
index ad884473ae..3dfa22cd1c 100644
--- a/versions.json
+++ b/versions.json
@@ -4,7 +4,7 @@
"version": "3.12.36"
},
"v4": {
- "version": "4.0.0-beta.231"
+ "version": "4.0.0-beta.232"
}
}
}