oneuptime/Workers/Utils/Cron.ts
Simon Larsen 8ec9569b69
fix lint
2022-11-02 17:40:04 +00:00

18 lines
490 B
TypeScript

import logger from 'CommonServer/Utils/Logger';
import cron from 'node-cron';
const RunCron = (jobName: string, schedule: string, runFunction: Function) => {
cron.schedule(schedule, async () => {
try {
logger.info(`Job ${jobName} Start`);
await runFunction();
logger.info(`Job ${jobName} End`);
} catch (e) {
logger.info(`Job ${jobName} Error`);
logger.error(e);
}
});
};
export default RunCron;