Skip to content

Commit 57d8930

Browse files
committed
chore: Update cleanup command to use Redis instead of queue
1 parent 688c27c commit 57d8930

11 files changed

+34
-114
lines changed

app/Console/Commands/CleanupQueue.php

Lines changed: 0 additions & 24 deletions
This file was deleted.

app/Console/Commands/CleanupRedis.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use Illuminate\Support\Facades\Redis;
7+
8+
class CleanupRedis extends Command
9+
{
10+
protected $signature = 'cleanup:redis';
11+
12+
protected $description = 'Cleanup Redis';
13+
14+
public function handle()
15+
{
16+
echo "Cleanup Redis keys.\n";
17+
$prefix = config('database.redis.options.prefix');
18+
19+
$keys = Redis::connection()->keys('*:laravel*');
20+
collect($keys)->each(function ($key) use ($prefix) {
21+
$keyWithoutPrefix = str_replace($prefix, '', $key);
22+
Redis::connection()->del($keyWithoutPrefix);
23+
});
24+
25+
$queueOverlaps = Redis::connection()->keys('*laravel-queue-overlap*');
26+
collect($queueOverlaps)->each(function ($key) {
27+
Redis::connection()->del($key);
28+
});
29+
30+
}
31+
}

app/Console/Commands/Init.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function handle()
5353
} else {
5454
$this->cleanup_in_progress_application_deployments();
5555
}
56-
$this->call('cleanup:queue');
56+
$this->call('cleanup:redis');
5757
$this->call('cleanup:stucked-resources');
5858

5959
if (isCloud()) {

app/Jobs/ContainerStatusJob.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Illuminate\Contracts\Queue\ShouldQueue;
1010
use Illuminate\Foundation\Bus\Dispatchable;
1111
use Illuminate\Queue\InteractsWithQueue;
12-
use Illuminate\Queue\Middleware\WithoutOverlapping;
1312
use Illuminate\Queue\SerializesModels;
1413

1514
class ContainerStatusJob implements ShouldBeEncrypted, ShouldQueue
@@ -25,16 +24,6 @@ public function backoff(): int
2524

2625
public function __construct(public Server $server) {}
2726

28-
public function middleware(): array
29-
{
30-
return [(new WithoutOverlapping($this->server->uuid))];
31-
}
32-
33-
public function uniqueId(): int
34-
{
35-
return $this->server->uuid;
36-
}
37-
3827
public function handle()
3928
{
4029
GetContainersStatus::run($this->server);

app/Jobs/DatabaseBackupJob.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use Illuminate\Contracts\Queue\ShouldQueue;
2424
use Illuminate\Foundation\Bus\Dispatchable;
2525
use Illuminate\Queue\InteractsWithQueue;
26-
use Illuminate\Queue\Middleware\WithoutOverlapping;
2726
use Illuminate\Queue\SerializesModels;
2827
use Illuminate\Support\Str;
2928
use Visus\Cuid2\Cuid2;
@@ -80,16 +79,6 @@ public function __construct($backup)
8079
}
8180
}
8281

83-
public function middleware(): array
84-
{
85-
return [new WithoutOverlapping($this->backup->id)];
86-
}
87-
88-
public function uniqueId(): int
89-
{
90-
return $this->backup->id;
91-
}
92-
9382
public function handle(): void
9483
{
9584
try {

app/Jobs/GithubAppPermissionJob.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Illuminate\Contracts\Queue\ShouldQueue;
99
use Illuminate\Foundation\Bus\Dispatchable;
1010
use Illuminate\Queue\InteractsWithQueue;
11-
use Illuminate\Queue\Middleware\WithoutOverlapping;
1211
use Illuminate\Queue\SerializesModels;
1312
use Illuminate\Support\Facades\Http;
1413

@@ -25,16 +24,6 @@ public function backoff(): int
2524

2625
public function __construct(public GithubApp $github_app) {}
2726

28-
public function middleware(): array
29-
{
30-
return [(new WithoutOverlapping($this->github_app->uuid))];
31-
}
32-
33-
public function uniqueId(): int
34-
{
35-
return $this->github_app->uuid;
36-
}
37-
3827
public function handle()
3928
{
4029
try {

app/Jobs/PullSentinelImageJob.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Illuminate\Contracts\Queue\ShouldQueue;
1010
use Illuminate\Foundation\Bus\Dispatchable;
1111
use Illuminate\Queue\InteractsWithQueue;
12-
use Illuminate\Queue\Middleware\WithoutOverlapping;
1312
use Illuminate\Queue\SerializesModels;
1413

1514
class PullSentinelImageJob implements ShouldBeEncrypted, ShouldQueue
@@ -18,16 +17,6 @@ class PullSentinelImageJob implements ShouldBeEncrypted, ShouldQueue
1817

1918
public $timeout = 1000;
2019

21-
public function middleware(): array
22-
{
23-
return [(new WithoutOverlapping($this->server->uuid))];
24-
}
25-
26-
public function uniqueId(): string
27-
{
28-
return $this->server->uuid;
29-
}
30-
3120
public function __construct(public Server $server) {}
3221

3322
public function handle(): void

app/Jobs/ScheduledTaskJob.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Illuminate\Contracts\Queue\ShouldQueue;
1414
use Illuminate\Foundation\Bus\Dispatchable;
1515
use Illuminate\Queue\InteractsWithQueue;
16-
use Illuminate\Queue\Middleware\WithoutOverlapping;
1716
use Illuminate\Queue\SerializesModels;
1817

1918
class ScheduledTaskJob implements ShouldQueue
@@ -67,16 +66,6 @@ private function getServerTimezone(): string
6766
return 'UTC';
6867
}
6968

70-
public function middleware(): array
71-
{
72-
return [new WithoutOverlapping($this->task->id)];
73-
}
74-
75-
public function uniqueId(): int
76-
{
77-
return $this->task->id;
78-
}
79-
8069
public function handle(): void
8170
{
8271

app/Jobs/ServerCheckJob.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616
use Illuminate\Contracts\Queue\ShouldQueue;
1717
use Illuminate\Foundation\Bus\Dispatchable;
1818
use Illuminate\Queue\InteractsWithQueue;
19-
use Illuminate\Queue\Middleware\WithoutOverlapping;
2019
use Illuminate\Queue\SerializesModels;
2120
use Illuminate\Support\Arr;
2221

2322
class ServerCheckJob implements ShouldBeEncrypted, ShouldQueue
2423
{
2524
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
2625

27-
public $tries = 3;
26+
public $tries = 1;
2827

2928
public $timeout = 60;
3029

@@ -45,16 +44,6 @@ public function backoff(): int
4544

4645
public function __construct(public Server $server) {}
4746

48-
public function middleware(): array
49-
{
50-
return [(new WithoutOverlapping($this->server->id))];
51-
}
52-
53-
public function uniqueId(): int
54-
{
55-
return $this->server->id;
56-
}
57-
5847
public function handle()
5948
{
6049
try {

app/Jobs/ServerLimitCheckJob.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Illuminate\Contracts\Queue\ShouldQueue;
1111
use Illuminate\Foundation\Bus\Dispatchable;
1212
use Illuminate\Queue\InteractsWithQueue;
13-
use Illuminate\Queue\Middleware\WithoutOverlapping;
13+
use Illuminate\Queue\Middleware\;
1414
use Illuminate\Queue\SerializesModels;
1515

1616
class ServerLimitCheckJob implements ShouldBeEncrypted, ShouldQueue
@@ -26,16 +26,6 @@ public function backoff(): int
2626

2727
public function __construct(public Team $team) {}
2828

29-
public function middleware(): array
30-
{
31-
return [(new WithoutOverlapping($this->team->uuid))];
32-
}
33-
34-
public function uniqueId(): int
35-
{
36-
return $this->team->uuid;
37-
}
38-
3929
public function handle()
4030
{
4131
try {

0 commit comments

Comments
 (0)