diff --git a/.vs/AACloudPlatform/v15/.suo b/.vs/AACloudPlatform/v15/.suo index 6b22e7c7e..aa52631ff 100644 Binary files a/.vs/AACloudPlatform/v15/.suo and b/.vs/AACloudPlatform/v15/.suo differ diff --git a/Trading Bot Main Loop.js b/Trading Bot Main Loop.js index 7735c9399..23c8cbe11 100644 --- a/Trading Bot Main Loop.js +++ b/Trading Bot Main Loop.js @@ -330,6 +330,7 @@ if (FULL_LOG === true) { logger.write("[INFO] run -> loopControl -> Stopping the Loop Gracefully. See you next time! :-)"); } callBackFunction(global.DEFAULT_OK_RESPONSE); + return; } @@ -357,7 +358,7 @@ try { vmConfig = JSON.parse(fs.readFileSync('this.vm.config.json', 'utf8')); - return vmConfig.stopGrafully; + return JSON.parse(vmConfig.stopGrafully); } catch (err) { const logText = "[ERROR] 'readConfig' - ERROR : " + err.message; diff --git a/Utilities.js b/Utilities.js index b2a0384c4..a0597dd93 100644 --- a/Utilities.js +++ b/Utilities.js @@ -1,6 +1,8 @@  exports.newUtilities = function newUtilities(BOT) { + const FULL_LOG = true; + let bot = BOT; const ROOT_DIR = '../'; @@ -20,54 +22,58 @@ exports.newUtilities = function newUtilities(BOT) { return utilities; - function pad(str, max) { - str = str.toString(); - return str.length < max ? pad("0" + str, max) : str; - } - function createFolderIfNeeded(path, azureFileStorage, callBackFunction) { - if (FULL_LOG === true) { logger.write("[INFO] createFolderIfNeeded -> Entering function."); } + try { - let splittedPath = path.split("/"); + if (FULL_LOG === true) { logger.write("[INFO] createFolderIfNeeded -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] createFolderIfNeeded -> path = " + path); } - let partialPath = ''; - let separator = ""; + let splittedPath = path.split("/"); - let i = 0; - loop(); + let partialPath = ''; + let separator = ""; - function loop() { + let i = 0; + loop(); - if (FULL_LOG === true) { logger.write("[INFO] createFolderIfNeeded -> loop -> Entering function."); } + function loop() { - partialPath = partialPath + separator + splittedPath[i]; - separator = "/"; + if (FULL_LOG === true) { logger.write("[INFO] createFolderIfNeeded -> path = " + path); } - i++; + partialPath = partialPath + separator + splittedPath[i]; + separator = "/"; - azureFileStorage.createFolder(partialPath, checkLoop); + i++; - function checkLoop(err) { + if (FULL_LOG === true) { logger.write("[INFO] createFolderIfNeeded -> partialPath = " + partialPath); } - if (FULL_LOG === true) { logger.write("[INFO] createFolderIfNeeded -> loop -> checkLoop -> Entering function."); } + azureFileStorage.createFolder(partialPath, checkLoop); - if (err.result !== global.DEFAULT_OK_RESPONSE.result) { - logger.write("[ERROR] createFolderIfNeeded -> loop -> checkLoop -> err = " + err.message); - callBackFunction(err); - return; - } + function checkLoop(err) { - if (i === splittedPath.length) { + if (FULL_LOG === true) { logger.write("[INFO] createFolderIfNeeded -> loop -> checkLoop -> Entering function."); } - callBackFunction(global.DEFAULT_OK_RESPONSE); + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + logger.write("[ERROR] createFolderIfNeeded -> loop -> checkLoop -> err = " + err.message); + callBackFunction(err); + return; + } - } else { + if (i === splittedPath.length) { - loop(); + callBackFunction(global.DEFAULT_OK_RESPONSE); + } else { + + loop(); + + } } } + } catch (err) { + logger.write("[ERROR] createFolderIfNeeded -> Error = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); } } @@ -81,7 +87,8 @@ exports.newUtilities = function newUtilities(BOT) { } } - - - + function pad(str, max) { + str = str.toString(); + return str.length < max ? pad("0" + str, max) : str; + } } \ No newline at end of file diff --git a/this.vm.config.json b/this.vm.config.json index 4d1d36e09..0d3f77473 100644 --- a/this.vm.config.json +++ b/this.vm.config.json @@ -2,5 +2,5 @@ "bot": { "path": "../Bots/AAMasters/AAMariam-Trading-Bot" }, - "stopGrafully": "false" + "stopGrafully": "true" } \ No newline at end of file