We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Code - var timers = require("timers"), http = require("http"), ___backgroundTimer;
process.on('message',function(msg){ console.log("Started 2");
this._longRunningTask = function(data){ var finalArray = []; console.log("Started 3"); for(var url in data){ //TODO do something here to create the 'result' finalArray.push("result"); console.log("Started 4"); } //Send the results back to index.js if(finalArray != []){ var data = { "error":null, "content":finalArray }; try{ console.log("Started 3.1"); console.log("datadatadata ",data) process.send(data); } catch(err){ console.log("retriever.js: problem with process.send() " + err.message + ", " + err.stack); } } else{ console.log("retriever.js: no data processed"); } }; this._startTimer = function(){ var count = 0; console.log("Started 33.1"); ___backgroundTimer = timers.setInterval(function(){ console.log("Started 33.2"); try{ var date = new Date(); console.log("retriever.js: datetime tick: " + date.toUTCString()); this._longRunningTask(msg.content); } catch(err){ count++; if(count == 3){ console.log("retriever.js: shutdown timer...too many errors. " + err.message); clearInterval(___backgroundTimer); process.disconnect(); } else{ console.log("retriever.js error: " + err.message + "\n" + err.stack); } } },msg.interval); } this._init = function(){ if(msg.content != null || msg.content != "" && msg.start == true){ this._startTimer(); console.log("msg.contentmsg.content"+msg.content); console.log("Started 33"); } else{ console.log("retriever.js: content empty. Unable to start timer."); console.log("Started 44") } }.bind(this)()
})
process.on('uncaughtException',function(err){ console.log("retriever.js: " + err.message + "\n" + err.stack + "\n Stopping background timer"); clearInterval(___backgroundTimer); })
The text was updated successfully, but these errors were encountered:
I'm not surprised, this code was built for a 0.x version of node.
My initial guess is you have to declare _longRunningTask , _startTimer and _init as a private variables first up at the top of the file.
_longRunningTask
_startTimer
_init
Sorry, something went wrong.
No branches or pull requests
Code -
var timers = require("timers"),
http = require("http"),
___backgroundTimer;
process.on('message',function(msg){
console.log("Started 2");
})
process.on('uncaughtException',function(err){
console.log("retriever.js: " + err.message + "\n" + err.stack + "\n Stopping background timer");
clearInterval(___backgroundTimer);
})
The text was updated successfully, but these errors were encountered: