feat: initialize CalBook project with comprehensive scheduling, admin, and deployment infrastructure
This commit is contained in:
24
lib/services/cron.ts
Normal file
24
lib/services/cron.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import cron from "node-cron";
|
||||
import { syncAllEnabledCalendars } from "@/lib/services/caldav";
|
||||
import { runAppointmentReminders } from "@/lib/services/reminders";
|
||||
|
||||
let started = false;
|
||||
|
||||
export function startSyncCron() {
|
||||
if (started || process.env.NODE_ENV === "test") return;
|
||||
started = true;
|
||||
|
||||
cron.schedule("*/5 * * * *", async () => {
|
||||
try {
|
||||
await Promise.all([
|
||||
syncAllEnabledCalendars(),
|
||||
runAppointmentReminders()
|
||||
]);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log("[calbook] CalDAV Sync ausgeführt");
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error("[calbook] CalDAV Sync Fehler", error);
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user