Refactor: Move Sentinel restart logic into processServerTasks method

This commit is contained in:
Andras Bacsai 2025-12-03 09:21:55 +01:00
parent f75bc85bc1
commit c982d58eee

View file

@ -129,6 +129,16 @@ private function processServerTasks(Server $server): void
} }
} }
$isSentinelEnabled = $server->isSentinelEnabled();
$shouldRestartSentinel = $isSentinelEnabled && $this->shouldRunNow('0 0 * * *', $serverTimezone);
// Dispatch Sentinel restart if due (daily for Sentinel-enabled servers)
if ($shouldRestartSentinel) {
dispatch(function () use ($server) {
$server->restartContainer('coolify-sentinel');
});
}
// Dispatch ServerStorageCheckJob if due (independent of Sentinel status) // Dispatch ServerStorageCheckJob if due (independent of Sentinel status)
$serverDiskUsageCheckFrequency = data_get($server->settings, 'server_disk_usage_check_frequency', '0 23 * * *'); $serverDiskUsageCheckFrequency = data_get($server->settings, 'server_disk_usage_check_frequency', '0 23 * * *');
if (isset(VALID_CRON_STRINGS[$serverDiskUsageCheckFrequency])) { if (isset(VALID_CRON_STRINGS[$serverDiskUsageCheckFrequency])) {
@ -147,15 +157,6 @@ private function processServerTasks(Server $server): void
ServerPatchCheckJob::dispatch($server); ServerPatchCheckJob::dispatch($server);
} }
// Dispatch Sentinel restart if due (daily for Sentinel-enabled servers)
$isSentinelEnabled = $server->isSentinelEnabled();
$shouldRestartSentinel = $isSentinelEnabled && $this->shouldRunNow('0 0 * * *', $serverTimezone);
if ($shouldRestartSentinel) {
dispatch(function () use ($server) {
$server->restartContainer('coolify-sentinel');
});
}
} }
private function shouldRunNow(string $frequency, ?string $timezone = null): bool private function shouldRunNow(string $frequency, ?string $timezone = null): bool