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

Graceful Shutdown | kue has no method 'shutdown' #291

Closed
oliverlloyd opened this issue Feb 5, 2014 · 4 comments
Closed

Graceful Shutdown | kue has no method 'shutdown' #291

oliverlloyd opened this issue Feb 5, 2014 · 4 comments

Comments

@oliverlloyd
Copy link

Is require('kue').shutdown() valid?

  var kue = require('kue');

  console.log('The kue object:')
  console.log(kue)

  // https://github.com/LearnBoost/kue#graceful-shutdown
  // process.on( 'SIGTERM', function ( sig ) {
  setTimeout(function(){
    kue.shutdown(function(err) {
      console.log( 'Kue is shut down.', err||'' );
      process.exit( 0 );
    }, 5000 );
  },5000);
  // });

Outputs:

5 Feb 12:45:07 - [nodemon] starting `node app/worker.js`
======================================================
The kue object:
{ [Function: Queue]
  version: '0.7.0',
  Job: 
   { [Function: Job]
     priorities: { low: 10, normal: 0, medium: -5, high: -10, critical: -15 },
     range: [Function],
     rangeByState: [Function],
     rangeByType: [Function],
     get: [Function],
     remove: [Function],
     log: [Function] },
  redis: 
   { createClient: [Function],
     client: [Function],
     pubsubClient: [Function] },
  createQueue: [Function],
  workers: [] }
2014-02-05T12:45:07.773Z - info: [worker] Node server running as: WORKER at: https://acac05e0.ipt.aol.com:5003
2014-02-05T12:45:08.266Z - info: [worker] Worker 1 taking job id 1634, [checkIndexes] from the main queue
2014-02-05T12:45:10.759Z - info: [worker] KUE Pending:  0
2014-02-05T12:45:10.760Z - info: [worker] KUE Active:  6

/Users/oliver/Code/XXX/app/server/modules/queue-manager.js:25
    kue.shutdown(function(err) {
        ^
TypeError: Object function Queue( options ) {
    options = options || {};
    this.client = redis.createClient( options.redis );
    this.promoter = null;
    this.workers = exports.workers;
    this.disableSearch = options.disableSearch;
} has no method 'shutdown'
    at null._onTimeout (/Users/oliver/Code/XXX/app/server/modules/queue-manager.js:25:9)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
5 Feb 12:45:12 - [nodemon] app crashed - waiting for file changes before starting...

Version:

  "name": "kue",
  "version": "0.7.3"
@behrad
Copy link
Collaborator

behrad commented Feb 5, 2014

sure no! you should call shutdown on your actual Queue object:

var q = require( 'kue' ).createQueue();
q.shutdown( ... )

Isn't it clear in the documentaion?

@behrad behrad closed this as completed Feb 5, 2014
@oliverlloyd
Copy link
Author

Ah... Semantics probably but no, not clear. As per docs [https://github.com/learnboost/kue#processing-jobs] we use the standard:

jobs = kue.createQueue();

I just never thought to look for the shutdown method against the jobs object but there it is, works now.

@oliverlloyd
Copy link
Author

#292

@behrad
Copy link
Collaborator

behrad commented Feb 5, 2014

This is a minor naming conflict. The popular jobs object all over the documentation is actually an instance of Queue prototype. may be queue is a better name, but semantically it is the jobs or job manager ;)
If you notice I have mentioned Queue#shutdown and also wrote queue not kue
but sure we should make it more clear.

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