feat(speedtest): worker + hourly cron + history/run routes
Adds speedtest pg-boss worker with injectable runner for testing, hourly cron enqueue, and /api/speedtest/history (GET) + /run (POST, owner-only) routes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import cron from 'node-cron';
|
||||
import { runSync } from './sync_source_docs.js';
|
||||
import { log } from '../log.js';
|
||||
import { enqueue } from '../jobs/queue.js';
|
||||
|
||||
export function startCron() {
|
||||
// Daily at 03:00 local time
|
||||
@@ -12,5 +13,12 @@ export function startCron() {
|
||||
log.error({ err: e }, 'cron sync.source_doc failed');
|
||||
}
|
||||
});
|
||||
|
||||
// Hourly speedtest
|
||||
cron.schedule('0 * * * *', async () => {
|
||||
try { await enqueue('speedtest', {}); log.info('cron speedtest enqueued'); }
|
||||
catch (e) { log.error({ err: e }, 'cron speedtest failed'); }
|
||||
});
|
||||
|
||||
log.info('cron started');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user