I know this topic has been discussed a lot but i cant manage to make it work.
Can someone post a clear example to explain how to achieve that functionality?
So to begin with,
I create the jobs dynamically. The user fills up a form to receive some alerts.
agenda.define('Test ' + index, function(job, done) {
doReport(user);
done();
});
parseWhen(report.when, function (err, data) {
var cronPattern = data.minute + ' '
+ data.hour + ' '
+ data.day_month + ' '
+ data.month + ' '
+ data.day_week + ' ';
agenda.every(cronPattern, 'Test ' + index);
agenda.start();
console.log("Agenda initted");
})
I make use of the graceful shut down as suggested in the documentation.
//Agenda configuration
var initAgenda = function () {
user.User.findOne({'slack.id':'U25V31BML'}, function (err, user) {
agenda = new Agenda();
agenda.database('mongodb://***');
agenda.processEvery('10 seconds');
agenda.on('ready', function() {
console.log('ready');
agenda.start();
for(var i = 0; i < user.reports.length; i++) {
createJob(user.reports[i], user);
}
})
});
}
Any suggestions?
+1
@mKontakis from the looks of it this should really be using the same job but with unique. Maybe that'll fix your issue?
If this isn't a problem anymore please consider closing the issue.
Follow ups: https://github.com/agenda/agenda/issues/410
Most helpful comment
+1