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.
41 lines
1.1 KiB
41 lines
1.1 KiB
const moment = require('moment')
|
|
const rimraf = require('rimraf');
|
|
const fs = require("fs");
|
|
const path = require("path")
|
|
|
|
let TEST = false
|
|
// TEST = true
|
|
|
|
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: TEST,
|
|
proRun: !TEST,
|
|
},
|
|
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 }
|
|
}
|