remove graph smoothing behavior, add null playerCount support

This commit is contained in:
Nick Krecklow
2020-05-11 03:10:23 -05:00
parent 19190f8d79
commit ef0c41ee1d
5 changed files with 89 additions and 51 deletions

View File

@ -92,8 +92,9 @@ class PingController {
const result = results[serverRegistration.serverId]
// Log to database if enabled
// Use null to represent a failed ping
if (config.logToDatabase) {
const playerCount = result.resp ? result.resp.players.online : 0
const playerCount = result.resp ? result.resp.players.online : null
this._app.database.insertPing(serverRegistration.data.ip, timestamp, playerCount)
}
@ -130,6 +131,12 @@ class PingController {
const version = serverRegistration.getNextProtocolVersion()
ping(serverRegistration, config.rates.connectTimeout, (err, resp) => {
if (Math.random() < 0.1) {
err = {
message: 'random fail'
}
resp = undefined
}
if (err) {
logger.log('error', 'Failed to ping %s: %s', serverRegistration.data.ip, err.message)
}