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 #61

Closed
wants to merge 6 commits into from
Closed

Graceful shutdown #61

wants to merge 6 commits into from

Conversation

ybogdanov
Copy link

Hi,

I've made graceful shutdown functionality.
The implementation is simple: Queue object collects all of it's workers, and then, when .shutdown() method is called, it propagates to all of them, and wait until all workers will done their current jobs (if there's some jobs in progress).

Also, added worker.running property to workers, to avoid new jobs pulling when shutting down. And ``worker.job` which points to current job in progress, to determine whether the worker is free or not.

To shutdown Kue object gracefully, simply use the following api:

var jobs = kue.createQueue();

// .. create jobs here

jobs.shutdown(function(err){
   // Kue is down
})

Closes #57

@tj
Copy link
Contributor

tj commented Aug 15, 2011

I think this is useful, but wouldn't it be more useful to use a signal? instead of a js-api?

* @return {String} escaped text
*/

function escape(html) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't really worry about xss, Kue should never be running on a public-facing port or anything like that

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, this is not about security. If a task title has html, it should be escaped and never rendered in Kue GUI as html. Shouldn't it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose, though I'm not sure when the title would have html

@ybogdanov
Copy link
Author

I think this is useful, but wouldn't it be more useful to use a signal? instead of a js-api?

In my app, I use both of. And both are useful.

process.once('SIGQUIT', function(){
    console.log('shutting down the queue..');
    jobs.shutdown(function(err){
        if (err) console.error(err);
        console.log('queue shutdown complete');
        process.exit();
    })
})

@tj
Copy link
Contributor

tj commented Aug 16, 2011

for sure, definitely stems from the js-api, I guess we could leave it as the method for now since cluster would need a slightly different solution as well

@bencevans
Copy link

Are there plans to merge this at all? It's a very useful feature 👍

@niftylettuce
Copy link

👍

1 similar comment
@Jellyfrog
Copy link
Contributor

👍

@bulkan
Copy link
Contributor

bulkan commented Jun 28, 2013

PR #121 has the changes here so we could possible close this issue too @drudge

Also, anyone interested in this PR or #121 until it gets merged, see https://github.com/LOKE/kue as we merged to our master.

@behrad
Copy link
Collaborator

behrad commented Jan 21, 2014

feature is introduced in #256

@behrad behrad closed this Jan 21, 2014
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

Successfully merging this pull request may close these issues.

What about graceful shutdown?
8 participants