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
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#