In my nodejs app, i have a file with following contents:
index.js contents:
var app = require('express')();
var http = require('http').Server(app);
function start(){
var timer = setTimeout(function(){
check();
clearTimeout(timer);
}, 60000); // 1 minutes
}
function check(){
// my custom codes....
console.log('checked');
start(); //return again to start
}
start();
http.listen(3008, function(){
console.log('listening on *:' + 3008);
});
Up code most check every 60 seconds my check
function.
this code is work, but there is a problem, when for example 5 users online in my app, i see in my console the check
function after 60 seconds was repeated !
//First 60 seconds
checked
//Second 60 seconds
checked
checked
//third 60 seconds
checked
checked
checked
checked
// check function repated again in each 60 seconds !
i try test several way, but not work.