Fix frontend not updating publicConfig.json
This changes the handshake sequence to use “bootTime” (a unique key based off the time) to make sure the frontend configuration matches the current one. If not, the client pulls the update and validates before requesting the listing.
This commit is contained in:
@ -4,6 +4,7 @@ var url = require('url');
|
||||
var mime = require('mime');
|
||||
var io = require('socket.io');
|
||||
|
||||
var util = require('./util');
|
||||
var logger = require('./logger');
|
||||
|
||||
var config = require('../config.json');
|
||||
@ -65,7 +66,8 @@ function handleRequest(req, res) {
|
||||
var publicConfig = {
|
||||
categories: categories,
|
||||
graphDuration: config.graphDuration,
|
||||
servers: servers
|
||||
servers: servers,
|
||||
bootTime: util.getBootTime()
|
||||
};
|
||||
|
||||
res.write('setPublicConfig(' + JSON.stringify(publicConfig) + ');');
|
||||
|
14
lib/util.js
14
lib/util.js
@ -3,7 +3,9 @@ var logger = require('./logger');
|
||||
var config = require('../config.json');
|
||||
var servers = require('../servers.json');
|
||||
|
||||
var serverNameLookup = {};
|
||||
var serverNameLookup = [];
|
||||
|
||||
var bootTime;
|
||||
|
||||
// Finds a server in servers.json with a matching IP.
|
||||
// If it finds one, it caches the result for faster future lookups.
|
||||
@ -136,4 +138,14 @@ exports.convertPingsToGraph = function(sqlData) {
|
||||
logger.info('Converted data structure in ' + (exports.getCurrentTimeMs() - startTime) + 'ms');
|
||||
|
||||
return graphData;
|
||||
};
|
||||
|
||||
exports.getBootTime = function() {
|
||||
if (!bootTime) {
|
||||
bootTime = exports.getCurrentTimeMs();
|
||||
|
||||
logger.info('Selected %d as boot time.', bootTime);
|
||||
}
|
||||
|
||||
return bootTime;
|
||||
};
|
Reference in New Issue
Block a user