提问者:小点点

使用bull和typescript的作业调度


我正在尝试用bull做一些调度。 这是我的代码

const avqueue = new Bull('avque');

avqueue.add({ video: '' }, { repeat: { cron: '*/50 * * * * *' }} );

avqueue.process( function(job, done) {
  console.log('avqueue');
  done();
});

但是它是在每毫秒内被执行的。如果我错过了任何参数或一些参数,请告诉我。


共1个答案

匿名用户

您在cron配置上出错。

cron:“*/50*****”是无效配置

cron配置只支持5个元素,而不支持6个元素。

正确的配置是:

cron: '*/50 * * * *'

在本bull指南中,您可以看到以下示例:

// Repeat every 10 seconds for 100 times.
const myJob = await myqueue.add(
  { foo: 'bar' },
  {
    repeat: {
      every: 10000,
      limit: 100
    }
  }
);

// Repeat payment job once every day at 3:15 (am)
paymentsQueue.add(paymentsData, { repeat: { cron: '15 3 * * *' } });