mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2024-11-30 08:01:19 +00:00
32 lines
722 B
JavaScript
32 lines
722 B
JavaScript
"use strict";
|
|
|
|
var fs = require("fs");
|
|
var path = require("path");
|
|
var winston = require("winston");
|
|
var client = require(path.join(__dirname, "../ensl/client"))();
|
|
var serverFile = path.join(__dirname, "../../config/data/servers.json");
|
|
|
|
const REFRESH_INTERVAL = 1000 * 60 * 60; // Check every hour
|
|
|
|
function Server () {
|
|
|
|
}
|
|
|
|
Server.list = JSON.parse(fs.readFileSync(serverFile)).servers;
|
|
|
|
Server.updateServerList = () => {
|
|
client.getServers((error, result) => {
|
|
if (error) {
|
|
winston.error("Unable to download server list")
|
|
winston.error(error);
|
|
return;
|
|
};
|
|
Server.list = result.servers;
|
|
});
|
|
};
|
|
|
|
Server.updateServerList();
|
|
|
|
setInterval(Server.updateServerList, REFRESH_INTERVAL);
|
|
|
|
module.exports = Server;
|