There is a script:
var timer = 0; function save_price() { var fs = require("fs"), request = require("request"), config = require('./server.config.js').config, IGetMarketPrices_URL = config.IGetMarketPrices_URL, myData = {"response":{"success":0,"message":"You can only request this page every 300 seconds per API key. Try again in 176 seconds."}}; timer = setInterval(function(){ request({ url: IGetMarketPrices_URL, json: true }, function (error, response, body) { if (!error && response.statusCode === 200) { myData = body; fs.writeFile('../var/www/prices.json', JSON.stringify(myData, null, 4), function(err) { if(err) console.log(err); else console.log("JSON saved to " + '../var/www/prices.json'); }); fs.writeFile('prices.json', JSON.stringify(myData, null, 4), function(err) { if(err) console.log(err); else console.log("JSON saved to " + 'prices.json'); }); } }); }, 10800000);//10800000 = каждые 3 часов //clearInterval(timer); //save_price(); } save_price(); Attention, the question is: why does the script eat 105 mb in 8 hours of uptime, although there is only one cycle running every 3 hours, is it possible to modernize it somehow?
Если код кривой, буду рад увидеть поправки, спасибо.
