LINXD-1029: Add relative path to simulator
This commit is contained in:
@ -106,6 +106,7 @@ class Mumble {
|
||||
// delay = delay used before reconnect
|
||||
console.log('------ Server reconnect...');
|
||||
utils.writeErrorLog(`ERROR_MUMBLE_RECONNECT`);
|
||||
// utils.exitWriteErrorLog(`ERROR_MUMBLE_RECONNECT`);
|
||||
})
|
||||
.on('disconnect', function (err) {
|
||||
// err = possible error
|
||||
|
@ -46,6 +46,7 @@ class Simulator {
|
||||
}
|
||||
fs.openSync('./logs/simulator.log', 'w');
|
||||
utils.writeLog('START');
|
||||
utils.writeLog(`process.env["NODE_CONFIG_DIR"]: ${process.env["NODE_CONFIG_DIR"]}`);
|
||||
|
||||
fs.openSync('./logs/error.log', 'w');
|
||||
});
|
||||
|
20
src/utils.js
20
src/utils.js
@ -1,8 +1,9 @@
|
||||
const config = require('config');
|
||||
const fs = require('fs');
|
||||
const moment = require('moment');
|
||||
const config = require('config');
|
||||
|
||||
let current_error_count = 0;
|
||||
let count_mumble_reconnect = 0;
|
||||
let max_fails = config.settings.max_fails;
|
||||
|
||||
module.exports.writeLog = async (value) => {
|
||||
@ -21,7 +22,7 @@ module.exports.writeErrorLog = async (value) => {
|
||||
|
||||
await fs.writeFile('./logs/error.log', `[${moment().format('YYYY-MM-DD HH:mm:ss')}] ${value} [${current_error_count}]\n`, {'flag':'a'}, (err) => {
|
||||
if (err) { reject(err); }
|
||||
else {
|
||||
else {
|
||||
if(current_error_count >= max_fails) {
|
||||
process.exit(0);
|
||||
}
|
||||
@ -29,4 +30,19 @@ module.exports.writeErrorLog = async (value) => {
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.exitWriteErrorLog = async (value) => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
console.log(`ERROR: ${value}`);
|
||||
await fs.writeFile('./logs/error.log', `[${moment().format('YYYY-MM-DD HH:mm:ss')}] ${value}\n`, {'flag':'a'}, (err) => {
|
||||
if (err) { reject(err); }
|
||||
else {
|
||||
if(count_mumble_reconnect >= max_fails) {
|
||||
process.exit(0);
|
||||
}
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user