feat(mvp): phase 4 - app registry & healthcheck
Add app CRUD API endpoints, healthcheck service with node-cron scheduler, icon resolver (Lucide, Simple Icons, CDN, uploads), app management UI with Superforms, health badge component, and Docker health endpoint.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import cron from 'node-cron';
|
||||
import { checkAllApps } from '$lib/server/services/healthcheckService.js';
|
||||
|
||||
let scheduledTask: cron.ScheduledTask | null = null;
|
||||
|
||||
/**
|
||||
* Start the healthcheck scheduler.
|
||||
* Runs checkAllApps on a cron schedule (default: every 60 seconds).
|
||||
*/
|
||||
export function startScheduler(cronExpression: string = '* * * * *'): void {
|
||||
if (scheduledTask) {
|
||||
return;
|
||||
}
|
||||
|
||||
scheduledTask = cron.schedule(cronExpression, async () => {
|
||||
try {
|
||||
await checkAllApps();
|
||||
} catch {
|
||||
// Swallow errors to prevent scheduler crash
|
||||
}
|
||||
});
|
||||
|
||||
// Run an initial check shortly after startup
|
||||
setTimeout(() => {
|
||||
checkAllApps().catch(() => {
|
||||
// Swallow initial check errors
|
||||
});
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the healthcheck scheduler.
|
||||
*/
|
||||
export function stopScheduler(): void {
|
||||
if (scheduledTask) {
|
||||
scheduledTask.stop();
|
||||
scheduledTask = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user