Gracefull stop of the loop

This commit is contained in:
Luis Fernando Molina committed 2018-03-09 10:31:46 +01:00
1 parent e65f320a36
commit 806762adf7
3 files changed
+29 -1

No files matched your search

Binary file not shown.
+27
View File
@@ -324,6 +324,15 @@
if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> nextWaitTime = " + nextWaitTime); }
/* Here we check if we must stop the loop gracefully. */
if (shallWeStop() === true) {
if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> Stopping the Loop Gracefully. See you next time! :-)"); }
callBackFunction(global.DEFAULT_OK_RESPONSE);
}
/* Trading bots are going to be executed after a configured period of time after the last execution ended. This is to avoid overlapping executions. */
switch (nextWaitTime) {
@@ -339,6 +348,24 @@
break;
}
}
function shallWeStop() {
var fs = require('fs');
let vmConfig;
try {
vmConfig = JSON.parse(fs.readFileSync('this.vm.config.json', 'utf8'));
return vmConfig.stopGrafully;
}
catch (err) {
const logText = "[ERROR] 'readConfig' - ERROR : " + err.message;
console.log(logText);
return;
}
}
}
catch (err) {
+2 -1
View File
@@ -1,5 +1,6 @@
{
"bot": {
"path": "../Bots/AAMasters/AAMariam-Trading-Bot"
}
},
"stopGrafully": "false"
}