Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with readme example #40

Closed
dadaista opened this issue Mar 22, 2014 · 10 comments
Closed

issue with readme example #40

dadaista opened this issue Mar 22, 2014 · 10 comments

Comments

@dadaista
Copy link

Hi, i took the example in readme and wrote a tryAgenda.js very simple

Agenda = require('agenda');
var agenda = new Agenda({db: { address: 'localhost:27017/agenda-example'}});
agenda.define('a task', function(job, done) {
console.log("a task is running ... say hello");
});
agenda.every('1 minutes', 'a task');
agenda.start();

but at runtime it exits with error ...see trace http://pastebin.com/QC4JMK2t

any hints?

@rschmukler
Copy link
Collaborator

Hey sorry for the delay. Your Mongo is likely too old a version. You need
at least Mongo 2.4+. Let me know if the works.

@dadaista
Copy link
Author

hi thank you, with 2.4.9 it starts nicely, but the task is executed only once :o. I supposed it was a periodic task.

D.

@rschmukler
Copy link
Collaborator

Can you run the following in the mongo console and paste the output....

db.agendaJobs.find().toArray()

@dadaista
Copy link
Author

[
{
"_id" : ObjectId("532f157d912a9cf106a6e1f0"),
"data" : null,
"lockedAt" : ISODate("2014-03-23T17:10:21.628Z"),
"name" : "a task",
"nextRunAt" : ISODate("2014-03-23T17:10:21.622Z"),
"priority" : 0,
"repeatInterval" : "1 minutes",
"type" : "single"
}
]

@jameswyse
Copy link

You forgot to call done() 😄

var Agenda = require('agenda');
var agenda = new Agenda({db: { address: 'localhost:27017/agenda-example'}});

agenda.define('a task', function(job, done) {
  console.log("a task is running ... say hello");
  done();
});

agenda.every('1 minutes', 'test');
agenda.start();
a task is running ... say hello
a task is running ... say hello
a task is running ... say hello
^C

@dadaista
Copy link
Author

Ooops, thanx. Now it works well on Ubuntu13/mongo2.4.9. Unfortunately there is another issue on OSX10.9.2/mongo2.4.8.

see paste http://pastebin.com/1CA9X9ZG

Another insidious aspect of this issue is that the error is presented only at first launch, if you relaunch the code it silently runs without actually executing tasks.

@rschmukler
Copy link
Collaborator

@dadaista that error is basically what happens when you try and run a job that isn't defined.

@dadaista
Copy link
Author

dadaista commented Apr 4, 2014

@rschmukler yeah, but the same code works well in ubuntu :o

@rschmukler
Copy link
Collaborator

@dadaista that's likely because the job that is undefined does not exist in your ubuntu database, but does in your other.

Can you give me the content of the agendaJobs database and the definition file so I can get a better idea of what's going on?

@rschmukler
Copy link
Collaborator

Closing for lack of activity, please re-open whenever you can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants