-
Notifications
You must be signed in to change notification settings - Fork 867
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
Shutdown not a function #783
Comments
Strange.... Can you debug what is exactly inside your |
queue contains {RedisClient} as expected as it does connect to the server and writing operations occured as expected. On the offending line that shows the exception, queue still not null. The debugger (VS Code on OS X) didn't let me dig further. I was able to replicate the problem without any additional package that I was using and pretty straightforward for what concern the usage of Kue. In the process I also found another issue for the graceful shutdown operation. See below for details. /*
repro issue #783 for Kue
*/
var kue = require('kue'); // queue management library
var queue = kue.createQueue({
prefix: 'q',
redis: {
port: 6379,
host: 'localhost',
auth: '',
db: 0,
options: {
}
}
});
var counterToStopWork = 0;
/* simple-job-queue */
function newJob(name) {
name = name || 'Default_Name';
var job = queue.create('new job', {
name: name
});
job
.on('complete', function() {
console.log('Job', job.id, 'with name', job.data.name, 'is done');
})
.on('failed', function() {
console.log('Job', job.id, 'with name', job.data.name, 'has failed');
});
job.save();
}
queue.process('new job', function(job, done) {
/* carry out all the job function here */
done && done();
});
setInterval(function() {
newJob('Send_Email');
counterToStopWork = counterToStopWork +1;
if (counterToStopWork == 5) {
queue.shutdown(2000, function(err) {
console.log('# Shutting down: ', err || '');
});
}
}, 3000);
//
// Shutdown grecefully if CTRL+C is pressed
//
// --->> DOESN'T WORK WHEN CTRL + C IS PRESSED IN TERMINAL <<<---
//
process.once('SIGTERM', function(sig) {
queue.shutdown(5000, function(err) {
console.log('# Graceful shutdown started: ', err || '');
process.exit(0);
});
}); |
Please make sure Ctrl+C on your terminal sends SIGTERM to your process. you can do this by adding a log before queue.shutdown call. |
I checked the documentation and it seems that the default ctrl+c on OSX sends a SIGTERM |
add a log to that line and test it your self in your console please that 2015-12-22 4:39 GMT+03:30 Mario notifications@github.com:
--Behrad |
Just to be clear, the main issue here is that shutdown throws an exception as reported. According to the documentation, my term (OSX) is configured by default to send a SIGTERM signal. In all cases that for me is not a scenario as I want to shutdown remotely (I have a hardware switch that works as expected for the callback purposes) |
Can you print out whats inside your |
Already done, It reported in my issue. it's a valid object ref as using that object I can read and write into redis. |
It should've been a |
I did post the code to repro in this thread. |
does seem a normal code! I'll try to run it locally. |
yep, that is what lead me to file the issue. It should just work. |
There was enough evidence but just to be double sure I step into the debugger a little further to validate your comment about the returning type. It is not a Queue object. /**
* Create a new `Queue`.
*
* @return {Queue}
* @api public
*/
exports.createQueue = function(){
return Queue.singleton = new Queue;
};
/**
* Initialize a new job `Queue`.
*
* @api public
*/
function Queue() {
this.client = redis.createClient();
} |
oh. Then in that case has to be something related with the packaging/modules. I will investigate and report back. |
after you pointed out the disparity of the returing object I figured what was the issue. |
Hello Kue team,
I have the following error
💥
queue.shutdown(2000, function(err) {
^
TypeError: queue.shutdown is not a function
at null. (/home/pi/code/iamsblog/sleepia/slogger.js:39:9)
at emitNone (events.js:67:13)
at emit (events.js:166:7)
From the documentation and the adviced received it all seems that I am doing the right thing, but the error still throwing.
I looked at this closed issues:
My code (gist)
Any help is appreciated and happy holidays!
;mE
The text was updated successfully, but these errors were encountered: