import { runHealthCheck } from "./healthMonitor.js"; import { runAutomationCheck } from "./automationMonitor.js"; // 15 minutes matches the agent's default report interval, so a check never sees "stale" data that's just waiting for the next report. const INTERVAL_MS = 15 * 60 * 1000; let timer: ReturnType | null = null; async function pass(): Promise { // Independent, so a failure in one never skips the other. try { await runHealthCheck(); } catch (err) { console.error("[health] check failed:", err); } try { await runAutomationCheck(); } catch (err) { console.error("[automation] check failed:", err); } } export async function initHealthScheduler(): Promise { if (timer) return; timer = setInterval(() => void pass(), INTERVAL_MS); // Not awaited: the first pass talks to Proxmox/Synology/Semaphore/Gitea and must not delay server startup. void pass(); console.log(`[health] checking server/storage health and automation runs every ${INTERVAL_MS / 60000} minutes`); }