Stop Gracefully fixed
This commit is contained in:
1 parent
806762adf7
commit
4b2a95a390
4 files changed
+41
-33
No files matched your search
Binary file not shown.
@@ -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;
|
||||
|
||||
+38
-31
@@ -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;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -2,5 +2,5 @@
|
||||
"bot": {
|
||||
"path": "../Bots/AAMasters/AAMariam-Trading-Bot"
|
||||
},
|
||||
"stopGrafully": "false"
|
||||
"stopGrafully": "true"
|
||||
}
|
||||
Reference in new issue
Block a user