2025-11-13 12:38:57 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Jobs;
|
|
|
|
|
|
|
|
|
|
use App\Enums\ProxyTypes;
|
|
|
|
|
use App\Models\Server;
|
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
|
|
|
|
|
|
class CheckTraefikVersionJob implements ShouldQueue
|
|
|
|
|
{
|
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
|
|
|
|
public $tries = 3;
|
|
|
|
|
|
|
|
|
|
public function handle(): void
|
|
|
|
|
{
|
2025-11-17 13:53:28 +00:00
|
|
|
// Load versions from cached data
|
|
|
|
|
$traefikVersions = get_traefik_versions();
|
2025-11-13 12:38:57 +00:00
|
|
|
|
2025-11-17 13:53:28 +00:00
|
|
|
if (empty($traefikVersions)) {
|
2025-11-17 08:59:17 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2025-11-13 12:38:57 +00:00
|
|
|
|
2025-11-17 08:59:17 +00:00
|
|
|
// Query all servers with Traefik proxy that are reachable
|
|
|
|
|
$servers = Server::whereNotNull('proxy')
|
|
|
|
|
->whereProxyType(ProxyTypes::TRAEFIK->value)
|
|
|
|
|
->whereRelation('settings', 'is_reachable', true)
|
|
|
|
|
->whereRelation('settings', 'is_usable', true)
|
|
|
|
|
->get();
|
2025-11-13 12:38:57 +00:00
|
|
|
|
2025-11-18 11:30:50 +00:00
|
|
|
if ($servers->isEmpty()) {
|
2025-11-17 08:59:17 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2025-11-13 12:38:57 +00:00
|
|
|
|
2025-11-17 08:59:17 +00:00
|
|
|
// Dispatch individual server check jobs in parallel
|
2025-11-18 11:30:50 +00:00
|
|
|
// Each job will send immediate notifications when outdated Traefik is detected
|
2025-11-17 08:59:17 +00:00
|
|
|
foreach ($servers as $server) {
|
|
|
|
|
CheckTraefikVersionForServerJob::dispatch($server, $traefikVersions);
|
|
|
|
|
}
|
2025-11-13 12:38:57 +00:00
|
|
|
}
|
|
|
|
|
}
|