Reputation: 7560
I have a sample program to start working with Agenda, and it gets stuck after running the first time.
var Agenda = require('agenda');
var agenda = new Agenda({db: {address: 'localhost/sample-dev', collection: 'pollingJob'}});
agenda.define('First1', function(job, done) {
var d = new Date();
console.log("Hello First Job at " + d );
});
agenda.on('ready', function() {
agenda.every('5 seconds', 'First1');
agenda.start();
});
I have done it all as per the instructions on Agenda, am I missing something out here?
Upvotes: 1
Views: 2032
Reputation: 103305
From the docs,
When a job of job name gets run, it will be passed to fn(job, done). To maintain asynchronous behavior, you must call done() when you are processing the job. If your function is synchronous, you may omit done from the signature.
So, from the above omit the callback and re-define the basic example as a synchronous job, like the following:
agenda.define('First1', function(job) {
var d = new Date();
console.log("Hello First Job at " + d );
});
agenda.on('ready', function() {
agenda.every('5 seconds', 'First1');
agenda.start();
});
Upvotes: 2