Skip to content

Commit

Permalink
fluff + version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Jul 16, 2019
1 parent 23f07a3 commit f4484f6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
14 changes: 10 additions & 4 deletions src/components/monitor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//Requires
const axios = require("axios");
const bigInt = require("big-integer");
const sleep = require('util').promisify(setTimeout);
const { dir, log, logOk, logWarn, logError, cleanTerminal } = require('../extras/console');
const helpers = require('../extras/helpers');
const HostCPUStatus = require('../extras/hostCPUStatus');
Expand Down Expand Up @@ -46,7 +47,7 @@ module.exports = class Monitor {
}, this.config.interval);
setInterval(() => {
this.checkRestartSchedule();
}, 59*1000); //Playing safe, right?
}, 60*1000);
}


Expand Down Expand Up @@ -128,7 +129,7 @@ module.exports = class Monitor {
if(action.restart === true){
let currTime = now.getHours().toString().padStart(2, '0') + ':' + now.getMinutes().toString().padStart(2, '0');
log(`Scheduled restart: ${currTime}`);
this.restartFXServer(`scheduled restart at ${currTime}`);
this.restartFXServer(`scheduled restart at ${currTime}`, 15);
}else if(typeof action.message === 'string'){
globals.discordBot.sendAnnouncement(action.message);
globals.fxRunner.srvCmd(`txaBroadcast "${action.message}"`);
Expand All @@ -137,11 +138,12 @@ module.exports = class Monitor {
}



//================================================================
/**
* Check cooldown and Restart the FXServer
*/
restartFXServer(reason){
async restartFXServer(reason, kickTime){
let elapsed = Math.round(Date.now()/1000) - globals.fxRunner.tsChildStarted;
if(elapsed >= this.config.restarter.cooldown){
//sanity check
Expand All @@ -150,9 +152,13 @@ module.exports = class Monitor {
return false;
}
let message = `Restarting server (${reason}).`;
globals.discordBot.sendAnnouncement(`Restarting **${globals.config.serverName}** (${reason}).`);
logWarn(message, context);
globals.discordBot.sendAnnouncement(`Restarting **${globals.config.serverName}** (${reason}).`);
globals.logger.append(`[MONITOR] ${message}`);
if(kickTime){
await globals.fxRunner.srvCmd(`txaKickAll "${message}"`);
await sleep(kickTime*1000);
}
globals.fxRunner.restartServer(reason);
}else{
if(globals.config.verbose) logWarn(`(Cooldown: ${elapsed}/${this.config.restarter.cooldown}s) restartFXServer() awaiting restarter cooldown.`, context);
Expand Down
6 changes: 5 additions & 1 deletion src/components/webConsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ module.exports = class webConsole {
this.io.use(sharedsession(globals.webServer.session));
this.io.use(this.authNewSession.bind(this));
this.io.on('connection', (socket) => {
log(`Connected: ${socket.id}`, contextSocket);
try {
log(`Connected: ${socket.handshake.session.auth.username} from ${socket.handshake.address}`, contextSocket);
} catch (error) {
log(`Connected: unknown`, contextSocket);
}

socket.on('disconnect', (reason) => {
log(`Client disconnected with reason: ${reason}`, contextSocket);
Expand Down
8 changes: 6 additions & 2 deletions version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.7.0",
"version": "1.7.1",
"changelog": "Deprecated Message. Please Update.",
"allVersions": [
{
Expand Down Expand Up @@ -28,7 +28,7 @@
},
{
"version": "1.1.0",
"changelog": "New Settings Page and setup script. Changed how server profiles work. Please read new instructions before updating."
"changelog": "New Settings Page and setup script. Changed how server profiles work. <br><h5><b>Please read update instructions on discord.</b></h5>"
},
{
"version": "1.2.0",
Expand All @@ -53,6 +53,10 @@
{
"version": "1.7.0",
"changelog": "Improved restarter behaviour. Minor bug fixes."
},
{
"version": "1.7.1",
"changelog": "Kicking players 15 seconds before scheduled restarts."
}
]
}

0 comments on commit f4484f6

Please sign in to comment.