Last Updated: February 25, 2016
·
800
· phaus

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();