feat(cron): daily sync.source_doc enqueue
node-cron schedules runSync at 03:00 local time; runSync enqueues sync.source_doc for every source_docs row with sync_source='url'. Started from server.js's CLI gate alongside the job queue. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
16
lib/cron/index.js
Normal file
16
lib/cron/index.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import cron from 'node-cron';
|
||||
import { runSync } from './sync_source_docs.js';
|
||||
import { log } from '../log.js';
|
||||
|
||||
export function startCron() {
|
||||
// Daily at 03:00 local time
|
||||
cron.schedule('0 3 * * *', async () => {
|
||||
try {
|
||||
const n = await runSync();
|
||||
log.info({ enqueued: n }, 'cron sync.source_doc complete');
|
||||
} catch (e) {
|
||||
log.error({ err: e }, 'cron sync.source_doc failed');
|
||||
}
|
||||
});
|
||||
log.info('cron started');
|
||||
}
|
||||
Reference in New Issue
Block a user