Update simulator

This commit is contained in:
Mihai Bozieru 2019-11-22 10:38:03 +00:00
parent 640c4b162e
commit ab52c0eff7
2 changed files with 10 additions and 8 deletions

View File

@ -12,6 +12,7 @@ let configs = {
assets: config.get('assets'),
sounds: config.get('sounds'),
settings: config.get('settings'),
elogs: config.get('elogs'),
}
// Start simulation.

View File

@ -10,7 +10,7 @@ class Simulator {
constructor(configs) {
this.configs = configs;
// Read assets ids from configs
this.assetIds = configs.assets.ids;
@ -37,19 +37,20 @@ class Simulator {
}
_manageLogs(callback) {
fs.readdir('logs', (err, files) => {
try {
fs.unlinkSync(path.join('logs/', 'error_'+this.configs.elogs.name+'.log'), err => {
if (err) throw err;
for (const file of files) {
fs.unlinkSync(path.join('logs', file), err => {
if (err) throw err;
});
}
});
fs.unlinkSync(path.join('logs/', 'simulator_'+this.configs.elogs.name+'.log'), err => {
if (err) throw err;
});
} catch(e) { console.log(e) }
fs.openSync('./logs/simulator_'+this.configs.elogs.name+'.log', 'w');
utils.writeLog('START');
utils.writeLog(`process.env["NODE_CONFIG_DIR"]: ${process.env["NODE_CONFIG_DIR"]}`);
fs.openSync('./logs/error_'+this.configs.elogs.name+'.log', 'w');
});
return callback();
}