5 files changed
+162
-1086
No files matched your search
@@ -15,7 +15,7 @@
|
||||
const DEBUG_MODULE = require(ROOT_DIR + 'DebugLog');
|
||||
let logger; // We need this here in order for the loopHealth function to work and be able to rescue the loop when it gets in trouble.
|
||||
|
||||
let nextLoopTimeoutHandle;
|
||||
let nextLoopTimeoutHandle;
|
||||
let checkLoopHealthHandle;
|
||||
|
||||
let thisObject = {
|
||||
@@ -24,7 +24,7 @@
|
||||
};
|
||||
|
||||
let processConfig;
|
||||
let UI_COMMANDS;
|
||||
let UI_COMMANDS;
|
||||
|
||||
return thisObject;
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
|
||||
if (FULL_LOG === true) { parentLogger.write(MODULE_NAME, "[INFO] run -> Entering function."); }
|
||||
|
||||
bot.enableCheckLoopHealth = true;
|
||||
bot.enableCheckLoopHealth = true;
|
||||
|
||||
let fixedTimeLoopIntervalHandle;
|
||||
|
||||
@@ -353,7 +353,7 @@
|
||||
try {
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeUserBot -> Entering function."); }
|
||||
|
||||
|
||||
usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES, BLOB_STORAGE);
|
||||
|
||||
usertBot.initialize(statusDependencies, pMonth, pYear, onInizialized);
|
||||
@@ -823,7 +823,10 @@
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> onStop -> Stopping the Loop Gracefully. See you next time!"); }
|
||||
|
||||
logger.persist();
|
||||
if(global.FULL_LOG === 'true'){
|
||||
logger.persist();
|
||||
}
|
||||
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE);
|
||||
return;
|
||||
|
||||
@@ -840,7 +843,9 @@
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> Restarting Loop in " + (processConfig.normalWaitTime / 1000) + " seconds."); }
|
||||
checkLoopHealthHandle = setTimeout(checkLoopHealth, processConfig.normalWaitTime * 5, bot.loopCounter);
|
||||
nextLoopTimeoutHandle = setTimeout(loop, processConfig.normalWaitTime);
|
||||
logger.persist();
|
||||
if(global.FULL_LOG === 'true'){
|
||||
logger.persist();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'Retry': {
|
||||
@@ -859,7 +864,7 @@
|
||||
case 'Coma': {
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> Restarting Loop in " + (processConfig.comaWaitTime / 3600000) + " hours."); }
|
||||
nextLoopTimeoutHandle = setTimeout(loop, processConfig.comaWaitTime);
|
||||
logger.persist();
|
||||
logger.persist();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -919,7 +924,7 @@
|
||||
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
let filePath = global.DEV_TEAM + "/" + "AACloud"; // DevTeams bots only are run at the cloud.
|
||||
|
||||
|
||||
let fileName = "this.config.json";
|
||||
|
||||
cloudStorage.getTextFile(filePath, fileName, onFileReceived);
|
||||
@@ -928,7 +933,7 @@
|
||||
|
||||
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
/*
|
||||
/*
|
||||
If for any reason this config file cannot be read, we are not going to abort the loop for that. Instead we are going to assume
|
||||
that there are no instructions to stop and we will keep the show running.
|
||||
*/
|
||||
|
||||
@@ -5,6 +5,7 @@ global.CURRENT_EXECUTION_AT = "Node";
|
||||
global.SHALL_BOT_STOP = false;
|
||||
global.AT_BREAKPOINT = false; // This is used only when running at the browser.
|
||||
global.RUN_AS_TEAM = false;
|
||||
global.FULL_LOG = process.env.FULL_LOG;
|
||||
|
||||
/* Default parameters can be changed by the execution configuration */
|
||||
global.EXCHANGE_NAME = process.env.EXCHANGE_NAME;
|
||||
@@ -100,7 +101,7 @@ function readExecutionConfiguration() {
|
||||
fixedInterval: fixedInterval
|
||||
}
|
||||
} else {
|
||||
console.log("[ERROR] readExecutionConfiguration -> Bot Type is invalid." );
|
||||
console.log("[ERROR] readExecutionConfiguration -> Bot Type is invalid.");
|
||||
throw new Error("readExecutionConfiguration -> Bot Type is invalid.")
|
||||
}
|
||||
|
||||
@@ -132,8 +133,8 @@ function readExecutionConfiguration() {
|
||||
}
|
||||
}
|
||||
|
||||
function getTimePeriod(timePeriod){
|
||||
if(timePeriod !== undefined){
|
||||
function getTimePeriod(timePeriod) {
|
||||
if (timePeriod !== undefined) {
|
||||
try {
|
||||
let timePeriodMap = new Map()
|
||||
timePeriodMap.set("24-hs", 86400000)
|
||||
@@ -157,7 +158,7 @@ function getTimePeriod(timePeriod){
|
||||
timePeriodMap.set("01-min", 60000)
|
||||
return timePeriodMap.get(timePeriod)
|
||||
} catch (error) {
|
||||
console.log( "[WARN] Run -> readExecutionConfiguration -> getTimePeriod -> Error: ", error);
|
||||
console.log("[WARN] Run -> readExecutionConfiguration -> getTimePeriod -> Error: ", error);
|
||||
}
|
||||
} else {
|
||||
return undefined
|
||||
@@ -166,7 +167,7 @@ function getTimePeriod(timePeriod){
|
||||
|
||||
function readStoragePermissions() {
|
||||
try {
|
||||
console.log( "[INFO] Run -> readStoragePermissions -> Entering function. ");
|
||||
console.log("[INFO] Run -> readStoragePermissions -> Entering function. ");
|
||||
|
||||
/* Dinamically generating the azure storage permissions for the bot to run */
|
||||
global.STORAGE_BASE_URL = process.env.STORAGE_BASE_URL
|
||||
@@ -221,7 +222,7 @@ function readStoragePermissions() {
|
||||
|
||||
function startRoot() {
|
||||
|
||||
console.log( "[INFO] Run -> startRoot -> Entering function. ");
|
||||
console.log("[INFO] Run -> startRoot -> Entering function. ");
|
||||
|
||||
const ROOT_DIR = './';
|
||||
const ROOT_MODULE = require(ROOT_DIR + 'Root');
|
||||
@@ -239,7 +240,7 @@ function startRoot() {
|
||||
|
||||
function onInitialized() {
|
||||
|
||||
console.log( "[INFO] Run -> startRoot -> onInitialized -> Entering function. ");
|
||||
console.log("[INFO] Run -> startRoot -> onInitialized -> Entering function. ");
|
||||
|
||||
root.start();
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
|
||||
const UTILITIES = require(ROOT_DIR + 'CloudUtilities');
|
||||
const STATUS_REPORT = require(ROOT_DIR + 'StatusReport');
|
||||
const EXCHANGE_API = require('@superalgos/exchangegateway');
|
||||
const EXCHANGE_API = require('@superalgos/exchange-gateway');
|
||||
const STATUS_DEPENDENCIES = require(ROOT_DIR + 'StatusDependencies');
|
||||
|
||||
/* We define the datetime for the process that we are running now. This will be the official processing time for both the infraestructure and the bot. */
|
||||
@@ -567,7 +567,11 @@
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> onStop -> Entering function."); }
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> onStop -> Stopping the Loop Gracefully. See you next time!"); }
|
||||
logger.persist();
|
||||
|
||||
if(global.FULL_LOG === 'true'){
|
||||
logger.persist();
|
||||
}
|
||||
|
||||
clearInterval(fixedTimeLoopIntervalHandle);
|
||||
clearTimeout(nextLoopTimeoutHandle);
|
||||
clearTimeout(checkLoopHealthHandle);
|
||||
@@ -588,13 +592,17 @@
|
||||
if (bot.runAtFixedInterval === true) {
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> Fixed Interval Normal exit point reached."); }
|
||||
checkLoopHealthHandle = setTimeout(checkLoopHealth, bot.fixedInterval * 5, bot.loopCounter);
|
||||
logger.persist();
|
||||
if(global.FULL_LOG === 'true'){
|
||||
logger.persist();
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> Restarting Loop in " + (processConfig.normalWaitTime / 1000) + " seconds."); }
|
||||
checkLoopHealthHandle = setTimeout(checkLoopHealth, processConfig.normalWaitTime * 5, bot.loopCounter);
|
||||
nextLoopTimeoutHandle = setTimeout(loop, processConfig.normalWaitTime);
|
||||
logger.persist();
|
||||
if(global.FULL_LOG === 'true'){
|
||||
logger.persist();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -163,7 +163,7 @@
|
||||
/* We define here all the modules that the rest of the infraestructure, including the bots themselves can consume. */
|
||||
|
||||
const UTILITIES = require(ROOT_DIR + 'CloudUtilities');
|
||||
const EXCHANGE_API = require('@superalgos/exchangegateway');
|
||||
const EXCHANGE_API = require('@superalgos/exchange-gateway');
|
||||
const CONTEXT = require(ROOT_DIR + 'Context');
|
||||
const ASSISTANT = require(ROOT_DIR + 'Assistant');
|
||||
const STATUS_REPORT = require(ROOT_DIR + 'StatusReport');
|
||||
@@ -1011,7 +1011,11 @@
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> onStop -> Entering function."); }
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> onStop -> Stopping the Loop Gracefully. See you next time!"); }
|
||||
logger.persist();
|
||||
|
||||
if(global.FULL_LOG === 'true' || bot.startMode === 'Competition'){
|
||||
logger.persist();
|
||||
}
|
||||
|
||||
clearInterval(fixedTimeLoopIntervalHandle);
|
||||
clearTimeout(nextLoopTimeoutHandle);
|
||||
clearTimeout(checkLoopHealthHandle);
|
||||
@@ -1032,7 +1036,9 @@
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> loopControl -> Normal -> Restarting Loop in " + (processConfig.normalWaitTime / 1000) + " seconds."); }
|
||||
checkLoopHealthHandle = setTimeout(checkLoopHealth, processConfig.normalWaitTime * 5, bot.loopCounter);
|
||||
nextLoopTimeoutHandle = setTimeout(loop, processConfig.normalWaitTime);
|
||||
logger.persist();
|
||||
if(global.FULL_LOG === 'true' || bot.startMode === 'Competition'){
|
||||
logger.persist();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'Retry': {
|
||||
|
||||
Generated
+119
-1063
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user