diff --git a/app.js b/app.js index 39230f7..9ba645b 100644 --- a/app.js +++ b/app.js @@ -185,6 +185,21 @@ var latencyTimeout = setInterval( function () client.write({ action: 'client-ping' }); }, 5000); + +// Cleanup old inactive nodes +var nodeCleanupTimeout = setInterval( function () +{ + client.write({ + action: 'init', + data: Nodes.all() + }); + + client.write({ + action: 'charts', + data: Nodes.getCharts() + }); +}, 1000*60); + // view engine setup app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'jade'); diff --git a/models/node.js b/models/node.js index a5dbc1a..b134db5 100644 --- a/models/node.js +++ b/models/node.js @@ -2,7 +2,7 @@ var geoip = require('geoip-lite'); var _ = require('lodash'); var MAX_HISTORY = 40; -var MAX_INACTIVE_TIME = 1000; +var MAX_INACTIVE_TIME = 1000*60*4; var Node = function Node(data) {