short test for background workers in NodeJS
#!/usr/bin/nodejs
var path = require('path');
#
# this is just a short test for worker threads in node.
#
# touch update => will trigger update functions
# touch stop => will stop Programm
#
var timerID;
function startTask(){
timerID = setInterval(function () {
console.log("step...");
if (path.existsSync("stop")) {
console.log("stopping");
clearInterval(timerID);
}
if (path.existsSync("update")) {
console.log("update...");
}
},5000);
console.log("starting:");
}
startTask();
Written by Philipp Haußleiter
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Async
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#