From ba7a7e96955c31d8b8c34bb4209e7b70907d6e82 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Jan 2024 13:33:57 +0100 Subject: [PATCH 1/5] Update server and version configurations --- app/Jobs/ContainerStatusJob.php | 8 +++----- app/Jobs/PullHelperImageJob.php | 2 +- config/sentry.php | 2 +- config/version.php | 2 +- versions.json | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php index b9fa3443f..86c879a3b 100644 --- a/app/Jobs/ContainerStatusJob.php +++ b/app/Jobs/ContainerStatusJob.php @@ -27,6 +27,9 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted { return isDev() ? 1 : 3; } + public function __construct(public Server $server) + { + } public function middleware(): array { return [(new WithoutOverlapping($this->server->uuid))]; @@ -37,11 +40,6 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted return $this->server->uuid; } - public function __construct(public Server $server) - { - $this->handle(); - } - public function handle() { if (!$this->server->isFunctional()) { diff --git a/app/Jobs/PullHelperImageJob.php b/app/Jobs/PullHelperImageJob.php index f06e9524d..848c316f2 100644 --- a/app/Jobs/PullHelperImageJob.php +++ b/app/Jobs/PullHelperImageJob.php @@ -19,7 +19,7 @@ class PullHelperImageJob implements ShouldQueue, ShouldBeEncrypted public function middleware(): array { - return [(new WithoutOverlapping($this->server->uuid))->dontRelease()]; + return [(new WithoutOverlapping($this->server->uuid))]; } public function uniqueId(): string diff --git a/config/sentry.php b/config/sentry.php index f1f17f030..ccae430a3 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.197', + 'release' => '4.0.0-beta.198', // 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 32e5b5873..e5829a919 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Thu, 18 Jan 2024 14:03:51 +0100 Subject: [PATCH 2/5] Update resource name in notification messages --- app/Notifications/Container/ContainerStopped.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Notifications/Container/ContainerStopped.php b/app/Notifications/Container/ContainerStopped.php index ac218c5fe..7bab74934 100644 --- a/app/Notifications/Container/ContainerStopped.php +++ b/app/Notifications/Container/ContainerStopped.php @@ -37,12 +37,12 @@ class ContainerStopped extends Notification implements ShouldQueue public function toDiscord(): string { - $message = "Coolify: A resource has been stopped unexpectedly on {$this->server->name}"; + $message = "Coolify: A resource ($this->name) has been stopped unexpectedly on {$this->server->name}"; return $message; } public function toTelegram(): array { - $message = "Coolify: A resource has been stopped unexpectedly on {$this->server->name}"; + $message = "Coolify: A resource ($this->name) has been stopped unexpectedly on {$this->server->name}"; $payload = [ "message" => $message, ]; From 8106602d155fa51c7db6976b46d8cf00b3c338c9 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Jan 2024 14:47:17 +0100 Subject: [PATCH 3/5] Add CleanupQueue command to clean up Redis queue keys --- app/Console/Commands/CleanupQueue.php | 22 ++++++++++++++++++++++ app/Console/Commands/Emails.php | 4 ---- app/Console/Kernel.php | 1 + 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 app/Console/Commands/CleanupQueue.php diff --git a/app/Console/Commands/CleanupQueue.php b/app/Console/Commands/CleanupQueue.php new file mode 100644 index 000000000..ac6562e5d --- /dev/null +++ b/app/Console/Commands/CleanupQueue.php @@ -0,0 +1,22 @@ +keys('*:laravel*'); + foreach ($keys as $key) { + $keyWithoutPrefix = str_replace($prefix, '', $key); + Redis::connection()->del($keyWithoutPrefix); + } + } +} diff --git a/app/Console/Commands/Emails.php b/app/Console/Commands/Emails.php index 821041002..86f317c96 100644 --- a/app/Console/Commands/Emails.php +++ b/app/Console/Commands/Emails.php @@ -9,8 +9,6 @@ use App\Models\ScheduledDatabaseBackup; use App\Models\Server; use App\Models\StandalonePostgresql; use App\Models\Team; -use App\Models\TeamInvitation; -use App\Models\User; use App\Models\Waitlist; use App\Notifications\Application\DeploymentFailed; use App\Notifications\Application\DeploymentSuccess; @@ -18,13 +16,11 @@ use App\Notifications\Application\StatusChanged; use App\Notifications\Database\BackupFailed; use App\Notifications\Database\BackupSuccess; use App\Notifications\Test; -use App\Notifications\TransactionalEmails\InvitationLink; use Exception; use Illuminate\Console\Command; use Illuminate\Mail\Message; use Illuminate\Notifications\Messages\MailMessage; use Mail; -use Illuminate\Support\Str; use function Laravel\Prompts\confirm; use function Laravel\Prompts\select; diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 50db6d681..16ad8c466 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -46,6 +46,7 @@ class Kernel extends ConsoleKernel $this->pull_helper_image($schedule); $this->check_scheduled_tasks($schedule); } + $schedule->command('cleanup:queue')->everyMinute()->onOneServer(); } private function pull_helper_image($schedule) { From 2f82dedd4f18685ab8c9a3fefea12a6555a25534 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Jan 2024 14:49:47 +0100 Subject: [PATCH 4/5] Add call to 'cleanup:queue' command in Init.php and remove 'cleanup:queue' command from Kernel.php --- app/Console/Commands/Init.php | 1 + app/Console/Kernel.php | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php index 2791a86f4..c88c52e8b 100644 --- a/app/Console/Commands/Init.php +++ b/app/Console/Commands/Init.php @@ -54,6 +54,7 @@ class Init extends Command $settings->update(['is_auto_update_enabled' => false]); } } + $this->call('cleanup:queue'); } private function restore_coolify_db_backup() { diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 16ad8c466..50db6d681 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -46,7 +46,6 @@ class Kernel extends ConsoleKernel $this->pull_helper_image($schedule); $this->check_scheduled_tasks($schedule); } - $schedule->command('cleanup:queue')->everyMinute()->onOneServer(); } private function pull_helper_image($schedule) { From 2db93bd9b9da8889fe783956942ffdb8ff5ac88d Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Jan 2024 14:56:12 +0100 Subject: [PATCH 5/5] Add echo statement for queue cleanup and update cleanup message --- app/Console/Commands/CleanupQueue.php | 1 + app/Console/Commands/Init.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Console/Commands/CleanupQueue.php b/app/Console/Commands/CleanupQueue.php index ac6562e5d..4d8fe8f6a 100644 --- a/app/Console/Commands/CleanupQueue.php +++ b/app/Console/Commands/CleanupQueue.php @@ -12,6 +12,7 @@ class CleanupQueue extends Command public function handle() { + echo "Running queue cleanup...\n"; $prefix = config('database.redis.options.prefix'); $keys = Redis::connection()->keys('*:laravel*'); foreach ($keys as $key) { diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php index c88c52e8b..798dcf275 100644 --- a/app/Console/Commands/Init.php +++ b/app/Console/Commands/Init.php @@ -30,7 +30,7 @@ class Init extends Command $this->alive(); $cleanup = $this->option('cleanup'); if ($cleanup) { - echo "Running cleanup\n"; + echo "Running cleanups...\n"; $this->cleanup_stucked_resources(); // Required for falsely deleted coolify db $this->restore_coolify_db_backup();