Files

11 lines
506 B
TypeScript

import {setTimeout as sleep} from 'node:timers/promises';
import {schedulerStep,recordSchedulerError} from './scheduler.ts';
// The worker shares SQLite leases with the API; restarting the container resumes scheduled runs.
for(;;){
let busy=false;
try{busy=await schedulerStep();}
catch(error){console.error('Scheduled audit failed; retrying in five seconds');try{await recordSchedulerError(error);}catch(storageError){console.error('Cannot save scheduler error');}}
await sleep(busy?350:5000);
}