| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- /**
- * Background work, started once per Node server.
- *
- * `DISABLE_BACKGROUND_JOBS=1` leaves every timer unstarted, which is what a
- * test harness wants: the schedulers otherwise tick through a run, writing to
- * the same rows the tests are asserting on (the due-reminder scan stamps
- * `notifiedAt`, the message and webhook processors send things) and competing
- * for the one CPU the suite is using. A spec that needs one of these calls the
- * processor itself instead of waiting for its timer.
- */
- export async function register() {
- if (process.env.NEXT_RUNTIME === 'nodejs') {
- if (process.env.DISABLE_BACKGROUND_JOBS === '1') {
- const { warnAboutAppUrl } = await import('./lib/auth-origin-hint')
- warnAboutAppUrl()
- const { markBackgroundJobsDisabled } = await import('./lib/background-jobs')
- markBackgroundJobsDisabled()
- const { createLogger } = await import('./lib/logger')
- createLogger('cron').info('DISABLE_BACKGROUND_JOBS=1, no scheduled work started')
- return
- }
- const {
- checkLicenses,
- syncSubscriptions,
- processRecurringInvoices,
- cleanupPortalSessions,
- sweepOrphanFilesDaily,
- cleanupAuditLogs,
- processReportSchedules,
- processWebhookDeliveries,
- cleanupWebhookDeliveries,
- startDemoResetCron,
- checkLowStock,
- checkDueReminders,
- processScheduledMessages,
- processAppointmentNotifications,
- processIntegrationJobs,
- cleanupIntegrationLogs,
- processBackupRuns,
- syncWorkshopHolidays,
- startHeartbeat,
- } = await import('./cronTasks')
- const { warnAboutAppUrl } = await import('./lib/auth-origin-hint')
- warnAboutAppUrl()
- checkLicenses()
- syncSubscriptions()
- processRecurringInvoices()
- cleanupPortalSessions()
- sweepOrphanFilesDaily()
- cleanupAuditLogs()
- processReportSchedules()
- startDemoResetCron()
- processWebhookDeliveries()
- cleanupWebhookDeliveries()
- checkLowStock()
- checkDueReminders()
- processScheduledMessages()
- processAppointmentNotifications()
- processIntegrationJobs()
- cleanupIntegrationLogs()
- processBackupRuns()
- syncWorkshopHolidays()
- // Last, so the health check only sees beats once everything above started.
- startHeartbeat()
- }
- }
|