mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2025-02-08 17:01:47 +00:00
28 lines
695 B
JavaScript
28 lines
695 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.updateServerList = function () {
|
|
client.getServers(function (error, result) {
|
|
if (error) winston.error("Unable to download server list", error);
|
|
Server.list = result.servers;
|
|
});
|
|
}
|
|
|
|
Server.list = JSON.parse(fs.readFileSync(serverFile)).servers;
|
|
|
|
Server.updateServerList();
|
|
|
|
setInterval(Server.updateServerList, REFRESH_INTERVAL);
|
|
|
|
module.exports = Server;
|