import logger from "./Logger";
import cron from "node-cron";
const BasicCron = async (props) => {
    const { jobName, options, runFunction } = props;
    cron.schedule(options.schedule, async () => {
        try {
            logger.debug(`Job ${jobName} Start`);
            await runFunction();
            logger.debug(`Job ${jobName} End`);
        }
        catch (e) {
            logger.debug(`Job ${jobName} Error`);
            logger.error(e);
        }
    });
    if (options.runOnStartup) {
        logger.debug(`Job ${jobName} - Start on Startup`);
        await runFunction();
    }
};
export default BasicCron;
//# sourceMappingURL=BasicCron.js.map