I need to create a function that can display a metric pulled at different hours of the day from an outside source one week ago. The way I have my server currently set up is usin
Something along these lines might help. Applying node cron to set the interval:
var net = require('net');
var port = Number(process.env.PORT || 3000)
var timeInMs = Date.now();
var weekInMs = 604800000;
var server = net.createServer(function (socket) {
//if time in Ms is time from first ping to now then...
socket.end(timeInMs + '\r\n');
});
server.listen(port);
The cron job:
var CronJob = require('cron').CronJob;
new CronJob('* * * * * *', function() {
console.log('You will see this message every second');
}, null, true, 'time zone');