政务数据资源中心(Government data Resource center)
03专项3期主要建设内容
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
const moment = require('moment')
|
|
|
|
|
|
|
|
module.exports = async function (app, opts) {
|
|
|
|
|
|
|
|
const jobs = {}
|
|
|
|
try {
|
|
|
|
const { models } = app.fs.dc
|
|
|
|
const tasks = await models.AcquisitionTask.findAll({
|
|
|
|
where: {
|
|
|
|
enabled: true
|
|
|
|
}
|
|
|
|
})
|
|
|
|
tasks.map(s => {
|
|
|
|
const job = app.fs.scheduleInit(
|
|
|
|
{
|
|
|
|
interval: s.cron,
|
|
|
|
immediate: true,
|
|
|
|
proRun: false,
|
|
|
|
},
|
|
|
|
async () => {
|
|
|
|
try {
|
|
|
|
console.log(s.taskName, moment().format('YYYY-MM-DD HH:mm:ss'));
|
|
|
|
} catch (error) {
|
|
|
|
app.fs.logger.error(`sechedule: taskJobs, error: ${error}`)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
jobs[s.id] = job;
|
|
|
|
})
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
app.fs.logger.error(`sechedule: acqTask, error: ${error}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
return { taskJobs: jobs }
|
|
|
|
}
|