Fix issues when logToDatabase is disabled.

This commit is contained in:
Cryptkeeper 2015-12-26 14:02:10 -06:00
parent 123967cac4
commit 7ea8332a52
2 changed files with 18 additions and 14 deletions

30
app.js

@ -89,20 +89,22 @@ function pingAll() {
// The same mechanic from trimUselessPings is seen here. // The same mechanic from trimUselessPings is seen here.
// If we dropped the ping, then to avoid destroying the graph, ignore it. // If we dropped the ping, then to avoid destroying the graph, ignore it.
// However if it's been too long since the last successful ping, we'll send it anyways. // However if it's been too long since the last successful ping, we'll send it anyways.
if (!lastGraphPush[network.ip] || (timeMs - lastGraphPush[network.ip] >= 60 * 1000 && res) || timeMs - lastGraphPush[network.ip] >= 70 * 1000) { if (config.logToDatabase) {
lastGraphPush[network.ip] = timeMs; if (!lastGraphPush[network.ip] || (timeMs - lastGraphPush[network.ip] >= 60 * 1000 && res) || timeMs - lastGraphPush[network.ip] >= 70 * 1000) {
lastGraphPush[network.ip] = timeMs;
// Don't have too much data! // Don't have too much data!
util.trimOldPings(graphData); util.trimOldPings(graphData);
graphData[network.ip].push([timeMs, res ? res.players.online : 0]); graphData[network.ip].push([timeMs, res ? res.players.online : 0]);
// Send the update. // Send the update.
server.io.sockets.emit('updateHistoryGraph', { server.io.sockets.emit('updateHistoryGraph', {
ip: network.ip, ip: network.ip,
players: (res ? res.players.online : 0), players: (res ? res.players.online : 0),
timestamp: timeMs timestamp: timeMs
}); });
}
} }
}); });
})(servers[i]); })(servers[i]);
@ -161,8 +163,10 @@ function startServices() {
}); });
client.on('requestHistoryGraph', function() { client.on('requestHistoryGraph', function() {
// Send them the big 24h graph. if (config.logToDatabase) {
client.emit('historyGraph', graphData); // Send them the big 24h graph.
client.emit('historyGraph', graphData);
}
}); });
}); });

@ -188,6 +188,6 @@
"pingAll": 2000, "pingAll": 2000,
"connectTimeout": 1500 "connectTimeout": 1500
}, },
"logToDatabase": true, "logToDatabase": false,
"graphDuration": 86400000 "graphDuration": 86400000
} }