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 to query all the active jobs programatically? #418

Closed
kithokit opened this issue Sep 24, 2014 · 5 comments
Closed

How to query all the active jobs programatically? #418

kithokit opened this issue Sep 24, 2014 · 5 comments

Comments

@kithokit
Copy link

I have stuck all the jobs in active state due to app crash.

How can we query all the active job in Kue and change back to inactive state programmicatlly?
Thanks a lot

Kit

@behrad
Copy link
Collaborator

behrad commented Sep 24, 2014

Something like this:

jobs.active( function( err, ids ) {
   ids.forEach( function( id ) {
      Job.get( id, function( err, job ) {
         job.inactive();
      }
   }
});

@kithokit
Copy link
Author

Yes. Got it Thanks a lot.

var kue = require('kue');
var jobs = kue.createQueue({
    prefix: 'kue',
    redis: {
      port: options.port,
      host: options.host,
      auth: options.password
    }
  });

// Restart the server , change all active job into active
  jobs.active( function( err, ids ) {
     ids.forEach( function( id ) {
        kue.Job.get( id, function( err, job ) {
           job.inactive();
        });
     });
  });

It should be like that.

@behrad
Copy link
Collaborator

behrad commented Sep 24, 2014

@kithokit Please remember to put your codes in related github markups, I did it for you this time ;)

@kithokit
Copy link
Author

Ok. Thanks a lot!

@meaku
Copy link

meaku commented Sep 24, 2014

Thanks @behrad!

@behrad behrad mentioned this issue Oct 24, 2014
@behrad behrad added this to the 0.9.0 milestone Dec 15, 2014
@behrad behrad closed this as completed in dd21078 Mar 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants