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

What is the right way to stop the worker? #11

Closed
5amfung opened this issue May 2, 2016 · 3 comments
Closed

What is the right way to stop the worker? #11

5amfung opened this issue May 2, 2016 · 3 comments

Comments

@5amfung
Copy link

5amfung commented May 2, 2016

For a simple example like the following, what is the right way to exit the program? I tried stop() at the end and it didn't seem to do anything.

worker.on("ready", function() {
    var i, len, msg, ref;
    ref = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
    for (i = 0, len = ref.length; i < len; i++) {
        msg = ref[i];
        console.log('SEND', msg);
        worker.send(msg);
    }
});
@mpneuried
Copy link
Owner

just call .stop().
https://github.com/mpneuried/rsmq-worker#stop

@mpneuried mpneuried self-assigned this May 3, 2016
@5amfung
Copy link
Author

5amfung commented May 3, 2016

That's what I thought too. Here's what I tried, but the script didn't stop. Am I missing something?

worker.start();
console.log('stop?');
worker.stop();

@mpneuried
Copy link
Owner

OK, now i can understand your need.
You want your script to end after the .stop(), right?
That was not the intension of .stop().
So i added a .quit() method with version 0.4.2.

Here's an extract of the changed docs:


.stop()

Just stop the receive interval.
This will not cut the connection to rsmq/redis.
If you want you script to end call .quit()

Return

( Self ): The instance itself for chaining.


.quit()

Stop the worker and close the connection.
After this it's no longer possible to reuse the worker-instance.
It's just intended to kill all timers and connections so your script will end.

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

2 participants