2023-09-14 10:45:50 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Jobs;
|
|
|
|
|
2024-05-07 13:41:50 +00:00
|
|
|
use App\Actions\Docker\GetContainersStatus;
|
2023-09-14 10:45:50 +00:00
|
|
|
use App\Models\Server;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
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;
|
|
|
|
|
2024-06-10 20:43:34 +00:00
|
|
|
class ContainerStatusJob implements ShouldBeEncrypted, ShouldQueue
|
2023-09-14 10:45:50 +00:00
|
|
|
{
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
2023-12-20 11:25:14 +00:00
|
|
|
public $tries = 4;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-12-19 14:16:08 +00:00
|
|
|
public function backoff(): int
|
|
|
|
{
|
2023-12-20 10:59:53 +00:00
|
|
|
return isDev() ? 1 : 3;
|
2023-12-19 14:16:08 +00:00
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-01-18 12:33:57 +00:00
|
|
|
public function __construct(public Server $server)
|
|
|
|
{
|
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-10-18 13:43:14 +00:00
|
|
|
public function middleware(): array
|
2023-09-14 10:45:50 +00:00
|
|
|
{
|
2023-12-20 10:59:06 +00:00
|
|
|
return [(new WithoutOverlapping($this->server->uuid))];
|
2023-09-14 10:45:50 +00:00
|
|
|
}
|
2023-10-13 12:25:30 +00:00
|
|
|
|
2023-10-18 13:43:14 +00:00
|
|
|
public function uniqueId(): int
|
2023-10-13 12:25:30 +00:00
|
|
|
{
|
2023-12-19 14:16:08 +00:00
|
|
|
return $this->server->uuid;
|
2023-10-13 12:25:30 +00:00
|
|
|
}
|
|
|
|
|
2023-11-22 14:18:37 +00:00
|
|
|
public function handle()
|
2023-09-14 10:45:50 +00:00
|
|
|
{
|
2024-05-08 12:53:48 +00:00
|
|
|
GetContainersStatus::run($this->server);
|
2023-09-14 10:45:50 +00:00
|
|
|
}
|
|
|
|
}
|