const moment = require('moment') const { handleTask } = require('./taskHandle'); //根据任务配置生成定时任务 module.exports = async function (app, task) { let job = null try { job = app.fs.scheduleInit( { interval: task.cron, immediate: true, proRun: false, }, async () => { try { await handleTask(app, task); console.log(task.taskName, moment().format('YYYY-MM-DD HH:mm:ss')); } catch (error) { app.fs.logger.error(`sechedule: taskJobs, error: ${error}`) } }); } catch (error) { app.fs.logger.error(`sechedule: taskJobs, error: ${error}`); } return job; }