mirror of
https://github.com/coollabsio/coolify.git
synced 2025-12-28 05:34:50 +00:00
Move notification logic from NotifyOutdatedTraefikServersJob into CheckTraefikVersionForServerJob to send immediate notifications when outdated Traefik is detected. This is more suitable for cloud environments with thousands of servers. Changes: - CheckTraefikVersionForServerJob now sends notifications immediately after detecting outdated Traefik - Remove NotifyOutdatedTraefikServersJob (no longer needed) - Remove delay calculation logic from CheckTraefikVersionJob - Update tests to reflect new immediate notification pattern Trade-offs: - Pro: Faster notifications (immediate alerts) - Pro: Simpler codebase (removed complex delay calculation) - Pro: Better scalability for thousands of servers - Con: Teams may receive multiple notifications if they have many outdated servers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?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
|
|
{
|
|
// Load versions from cached data
|
|
$traefikVersions = get_traefik_versions();
|
|
|
|
if (empty($traefikVersions)) {
|
|
return;
|
|
}
|
|
|
|
// 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();
|
|
|
|
if ($servers->isEmpty()) {
|
|
return;
|
|
}
|
|
|
|
// Dispatch individual server check jobs in parallel
|
|
// Each job will send immediate notifications when outdated Traefik is detected
|
|
foreach ($servers as $server) {
|
|
CheckTraefikVersionForServerJob::dispatch($server, $traefikVersions);
|
|
}
|
|
}
|
|
}
|