1

I am trying to use agenda to schedule jobs at a certain date and time, but the jobs are not running when the specified date is reached.

This is how I'm creating the job:

agenda.create(type, data)
.schedule(new Date(startDate))
.repeatEvery('11 21 * * *', {timezone: 'Europe/Bucharest'})
.save();

This is how I start agenda:

const Agenda = require('agenda');
const mongoDB = process.env.DB_PATH;

const mongoConnectionString = mongoDB;

let agenda = new Agenda({db: {address: mongoConnectionString, collection: 'jobs'}});

let jobTypes = process.env.JOB_TYPES ? process.env.JOB_TYPES.split(',') : [];

jobTypes.forEach(function(type) {
  require('./jobs/' + type)(agenda);
});

if(jobTypes.length) {
  agenda.on('ready', function() {
    console.log('agenda start')
    agenda.start();
  });
}

function graceful() {
    agenda.stop(function() {
      process.exit(0);
    });
}

process.on('SIGTERM', graceful);
process.on('SIGINT' , graceful);

export default agenda;

This is an example with a job that didn't start on the scheduled date:

enter image description here

Is there something I'm doing wrong?

EDIT: The job is triggered if I do schedule(new Date()), but it won't using a defined date.

Valip
  • 4,440
  • 19
  • 79
  • 150
  • There's no evidence that jobTypes includes the job you listed. – Estus Flask Mar 29 '19 at 11:28
  • It's included from the environment variables. If I do `schedule(new Date())` then it works fine, but it simply doesn't triggers the job with a specified date – Valip Mar 29 '19 at 11:39

0 Answers0