mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-23 07:42:10 +00:00
18 lines
490 B
TypeScript
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;
|