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.

chore: Update cleanup command to use Redis instead of queue

Andras Bacsai57d8930f9ec2
diff --git a/app/Console/Commands/CleanupQueue.php b/app/Console/Commands/CleanupQueue.php
deleted file mode 100644
index fd2b637acb..0000000000
--- a/app/Console/Commands/CleanupQueue.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-namespace App\Console\Commands;
-
-use Illuminate\Console\Command;
-use Illuminate\Support\Facades\Redis;
-
-class CleanupQueue extends Command
-{
- protected $signature = 'cleanup:queue';
-
- protected $description = 'Cleanup Queue';
-
- public function handle()
- {
- echo "Running queue cleanup...\n";
- $prefix = config('database.redis.options.prefix');
- $keys = Redis::connection()->keys('*:laravel*');
- foreach ($keys as $key) {
- $keyWithoutPrefix = str_replace($prefix, '', $key);
- Redis::connection()->del($keyWithoutPrefix);
- }
- }
-}
diff --git a/app/Console/Commands/CleanupRedis.php b/app/Console/Commands/CleanupRedis.php
new file mode 100644
index 0000000000..ed0740d34f
--- /dev/null
+++ b/app/Console/Commands/CleanupRedis.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace App\Console\Commands;
+
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Redis;
+
+class CleanupRedis extends Command
+{
+ protected $signature = 'cleanup:redis';
+
+ protected $description = 'Cleanup Redis';
+
+ public function handle()
+ {
+ echo "Cleanup Redis keys.\n";
+ $prefix = config('database.redis.options.prefix');
+
+ $keys = Redis::connection()->keys('*:laravel*');
+ collect($keys)->each(function ($key) use ($prefix) {
+ $keyWithoutPrefix = str_replace($prefix, '', $key);
+ Redis::connection()->del($keyWithoutPrefix);
+ });
+
+ $queueOverlaps = Redis::connection()->keys('*laravel-queue-overlap*');
+ collect($queueOverlaps)->each(function ($key) {
+ Redis::connection()->del($key);
+ });
+
+ }
+}
diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php
index 3c31ffad23..2f5d361400 100644
--- a/app/Console/Commands/Init.php
+++ b/app/Console/Commands/Init.php
@@ -53,7 +53,7 @@ class Init extends Command
} else {
$this->cleanup_in_progress_application_deployments();
}
- $this->call('cleanup:queue');
+ $this->call('cleanup:redis');
$this->call('cleanup:stucked-resources');
if (isCloud()) {
diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php
index e919855d55..22ae06ebde 100644
--- a/app/Jobs/ContainerStatusJob.php
+++ b/app/Jobs/ContainerStatusJob.php
@@ -9,7 +9,6 @@ use Illuminate\Contracts\Queue\ShouldBeEncrypted;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Queue\SerializesModels;
class ContainerStatusJob implements ShouldBeEncrypted, ShouldQueue
@@ -25,16 +24,6 @@ class ContainerStatusJob implements ShouldBeEncrypted, ShouldQueue
public function __construct(public Server $server) {}
- public function middleware(): array
- {
- return [(new WithoutOverlapping($this->server->uuid))];
- }
-
- public function uniqueId(): int
- {
- return $this->server->uuid;
- }
-
public function handle()
{
GetContainersStatus::run($this->server);
diff --git a/app/Jobs/DatabaseBackupJob.php b/app/Jobs/DatabaseBackupJob.php
index 3bd13564bf..947dc4317e 100644
--- a/app/Jobs/DatabaseBackupJob.php
+++ b/app/Jobs/DatabaseBackupJob.php
@@ -23,7 +23,6 @@ use Illuminate\Contracts\Queue\ShouldBeEncrypted;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Str;
use Visus\Cuid2\Cuid2;
@@ -80,16 +79,6 @@ class DatabaseBackupJob implements ShouldBeEncrypted, ShouldQueue
}
}
- public function middleware(): array
- {
- return [new WithoutOverlapping($this->backup->id)];
- }
-
- public function uniqueId(): int
- {
- return $this->backup->id;
- }
-
public function handle(): void
{
try {
diff --git a/app/Jobs/GithubAppPermissionJob.php b/app/Jobs/GithubAppPermissionJob.php
index 3188d35d6e..9c0a2b55b0 100644
--- a/app/Jobs/GithubAppPermissionJob.php
+++ b/app/Jobs/GithubAppPermissionJob.php
@@ -8,7 +8,6 @@ use Illuminate\Contracts\Queue\ShouldBeEncrypted;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Http;
@@ -25,16 +24,6 @@ class GithubAppPermissionJob implements ShouldBeEncrypted, ShouldQueue
public function __construct(public GithubApp $github_app) {}
- public function middleware(): array
- {
- return [(new WithoutOverlapping($this->github_app->uuid))];
- }
-
- public function uniqueId(): int
- {
- return $this->github_app->uuid;
- }
-
public function handle()
{
try {
diff --git a/app/Jobs/PullSentinelImageJob.php b/app/Jobs/PullSentinelImageJob.php
index f8c7693823..32f84e6d50 100644
--- a/app/Jobs/PullSentinelImageJob.php
+++ b/app/Jobs/PullSentinelImageJob.php
@@ -9,7 +9,6 @@ use Illuminate\Contracts\Queue\ShouldBeEncrypted;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Queue\SerializesModels;
class PullSentinelImageJob implements ShouldBeEncrypted, ShouldQueue
@@ -18,16 +17,6 @@ class PullSentinelImageJob implements ShouldBeEncrypted, ShouldQueue
public $timeout = 1000;
- public function middleware(): array
- {
- return [(new WithoutOverlapping($this->server->uuid))];
- }
-
- public function uniqueId(): string
- {
- return $this->server->uuid;
- }
-
public function __construct(public Server $server) {}
public function handle(): void
diff --git a/app/Jobs/ScheduledTaskJob.php b/app/Jobs/ScheduledTaskJob.php
index 3752164931..6850ae98a9 100644
--- a/app/Jobs/ScheduledTaskJob.php
+++ b/app/Jobs/ScheduledTaskJob.php
@@ -13,7 +13,6 @@ use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Queue\SerializesModels;
class ScheduledTaskJob implements ShouldQueue
@@ -67,16 +66,6 @@ class ScheduledTaskJob implements ShouldQueue
return 'UTC';
}
- public function middleware(): array
- {
- return [new WithoutOverlapping($this->task->id)];
- }
-
- public function uniqueId(): int
- {
- return $this->task->id;
- }
-
public function handle(): void
{
diff --git a/app/Jobs/ServerCheckJob.php b/app/Jobs/ServerCheckJob.php
index be5ec20f9a..7fde44f499 100644
--- a/app/Jobs/ServerCheckJob.php
+++ b/app/Jobs/ServerCheckJob.php
@@ -16,7 +16,6 @@ use Illuminate\Contracts\Queue\ShouldBeEncrypted;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Arr;
@@ -24,7 +23,7 @@ class ServerCheckJob implements ShouldBeEncrypted, ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- public $tries = 3;
+ public $tries = 1;
public $timeout = 60;
@@ -45,16 +44,6 @@ class ServerCheckJob implements ShouldBeEncrypted, ShouldQueue
public function __construct(public Server $server) {}
- public function middleware(): array
- {
- return [(new WithoutOverlapping($this->server->id))];
- }
-
- public function uniqueId(): int
- {
- return $this->server->id;
- }
-
public function handle()
{
try {
diff --git a/app/Jobs/ServerLimitCheckJob.php b/app/Jobs/ServerLimitCheckJob.php
index 24292025bd..b2c816f5d0 100644
--- a/app/Jobs/ServerLimitCheckJob.php
+++ b/app/Jobs/ServerLimitCheckJob.php
@@ -10,7 +10,7 @@ use Illuminate\Contracts\Queue\ShouldBeEncrypted;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\Middleware\WithoutOverlapping;
+use Illuminate\Queue\Middleware\;
use Illuminate\Queue\SerializesModels;
class ServerLimitCheckJob implements ShouldBeEncrypted, ShouldQueue
@@ -26,16 +26,6 @@ class ServerLimitCheckJob implements ShouldBeEncrypted, ShouldQueue
public function __construct(public Team $team) {}
- public function middleware(): array
- {
- return [(new WithoutOverlapping($this->team->uuid))];
- }
-
- public function uniqueId(): int
- {
- return $this->team->uuid;
- }
-
public function handle()
{
try {
diff --git a/app/Jobs/ServerStatusJob.php b/app/Jobs/ServerStatusJob.php
index ac9182ecaf..fcc33c8594 100644
--- a/app/Jobs/ServerStatusJob.php
+++ b/app/Jobs/ServerStatusJob.php
@@ -8,7 +8,6 @@ use Illuminate\Contracts\Queue\ShouldBeEncrypted;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Queue\SerializesModels;
class ServerStatusJob implements ShouldBeEncrypted, ShouldQueue
@@ -26,16 +25,6 @@ class ServerStatusJob implements ShouldBeEncrypted, ShouldQueue
public function __construct(public Server $server) {}
- public function middleware(): array
- {
- return [(new WithoutOverlapping($this->server->uuid))];
- }
-
- public function uniqueId(): int
- {
- return $this->server->uuid;
- }
-
public function handle()
{
if (! $this->server->isServerReady($this->tries)) {