我正在使用由 MongoDB 支持的带有 Node 的议程.js 来处理批处理作业。我正在使用的当前语法遇到的一个问题是安排重复事件,但没有立即执行。我知道“skipImmediate:true”标志,但我不清楚在我当前的配置中我需要在哪里应用它,我在哪里使用 IIFE:
agenda.define('test job', {
priority: 'high',
concurrency: 10
}, async job => {
const {
to
} = job.attrs.data;
job.repeatEvery('0 11 * * 1-5', {
skipImmediate: true
});
await send(to);
});
function send(to) {
const today = new Date();
const target = to;
const time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
console.log(`Emailing to ${target} regarding second job, at ${time}.`);
}
(async function () {
await agenda.start();
agenda.create('test job', {
to: 'someone@email.com',
from: 'sample@email.com'
}).save();
})();
};
如你所见,我有...
{ skipImmediate: true }
...在repeatEvery
块中,但它似乎不起作用。如何使用当前配置防止立即执行?