Refactor: Move sentinel update checks to ServerManagerJob and add tests for hourly dispatch

This commit is contained in:
Andras Bacsai committed 2025-12-04 14:58:18 +01:00
1 parent 2302a70a44
commit 4002044877
4 files changed
+338 -12

No files matched your search

+1 -12
View File
@@ -2,7 +2,6 @@
namespace App\Console;
use App\Jobs\CheckAndStartSentinelJob;
use App\Jobs\CheckForUpdatesJob;
use App\Jobs\CheckHelperImageJob;
use App\Jobs\CheckTraefikVersionJob;
@@ -100,17 +99,7 @@ class Kernel extends ConsoleKernel
} else {
$servers = $this->allServers->whereRelation('settings', 'is_usable', true)->whereRelation('settings', 'is_reachable', true)->get();
}
foreach ($servers as $server) {
try {
if ($server->isSentinelEnabled()) {
$this->scheduleInstance->job(function () use ($server) {
CheckAndStartSentinelJob::dispatch($server);
})->cron($this->updateCheckFrequency)->timezone($this->instanceTimezone)->onOneServer();
}
} catch (\Exception $e) {
Log::error('Error pulling images: '.$e->getMessage());
}
}
// Sentinel update checks are now handled by ServerManagerJob
$this->scheduleInstance->job(new CheckHelperImageJob)
->cron($this->updateCheckFrequency)
->timezone($this->instanceTimezone)
+9
View File
@@ -146,6 +146,15 @@ class ServerManagerJob implements ShouldQueue
ServerPatchCheckJob::dispatch($server);
}
// Check for sentinel updates hourly (independent of user-configurable update_check_frequency)
if ($server->isSentinelEnabled()) {
$shouldCheckSentinel = $this->shouldRunNow('0 * * * *', $serverTimezone);
if ($shouldCheckSentinel) {
CheckAndStartSentinelJob::dispatch($server);
}
}
// Dispatch Sentinel restart if due (daily for Sentinel-enabled servers)
$isSentinelEnabled = $server->isSentinelEnabled();
$shouldRestartSentinel = $isSentinelEnabled && $this->shouldRunNow('0 0 * * *', $serverTimezone);