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

How are jobs persisted when server is restarted? #58

Closed
artworkad opened this issue Apr 27, 2014 · 3 comments
Closed

How are jobs persisted when server is restarted? #58

artworkad opened this issue Apr 27, 2014 · 3 comments

Comments

@artworkad
Copy link

When I create a job to run every 10 minutes from a running node instance, it works fine. However when I restart the node server, the jobs are not started again.

While my app is initializing I do:

global.agenda = new require('agenda')({
    db: {
        address: 'USER:PASSWORD@localhost:27017/agenda',
        collection: 'jobs'
    },
    processEvery: '30 seconds',
    maxConcurrency: 100
});

global.agenda.start();

I bind a job to a model of my app when the model is created:

agenda.define(model.id, function(job, done) {
    //do something
    done();
}); 
agenda.every('10 minutes', model.id);

This works when the job is created and while nodejs is running. However when nodejs is restarted, the jobs do not run.

Am I missing something?

@artworkad
Copy link
Author

So at the moment I am purging the database when my server is restarted and recreate all jobs.

@rschmukler
Copy link
Collaborator

@artworkad sorry for the delay. See #59 for a description of what I think is going wrong. We can confirm this by running in mongo:

db.agendaJobs.findAll().toArray();

See if the jobs that are stuck have a lockedAt set.

@rschmukler
Copy link
Collaborator

I suspect that your issue was indeed locking. This has been fixed and release in 0.6.8. See the documentation graceful shutdown. Feel free to reopen if you have further problems.

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

2 participants