From 5d73304b6d6c40687a1b2d8ed0465426787beb56 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 25 Nov 2020 15:55:11 +0100 Subject: [PATCH] Globals Module --- TaskServer/Globals.js | 344 ++++++++++++++++++++++++++++++++++++++++++ TaskServer/Root.js | 57 ------- TaskServer/server.js | 318 ++------------------------------------ 3 files changed, 353 insertions(+), 366 deletions(-) create mode 100644 TaskServer/Globals.js diff --git a/TaskServer/Globals.js b/TaskServer/Globals.js new file mode 100644 index 000000000..33307356b --- /dev/null +++ b/TaskServer/Globals.js @@ -0,0 +1,344 @@ +exports.newGlobals = function newGlobals() { + + let thisObject = { + initialize: initialize + } + + return thisObject; + + function initialize() { + + /* Callbacks default responses. */ + global.DEFAULT_OK_RESPONSE = { + result: "Ok", + message: "Operation Succeeded" + }; + + global.DEFAULT_FAIL_RESPONSE = { + result: "Fail", + message: "Operation Failed" + }; + + global.DEFAULT_RETRY_RESPONSE = { + result: "Retry", + message: "Retry Later" + }; + + global.CUSTOM_OK_RESPONSE = { + result: "Ok, but check Message", + message: "Custom Message" + }; + + global.CUSTOM_FAIL_RESPONSE = { + result: "Fail Because", + message: "Custom Message" + }; + + /* This is the Execution Datetime */ + + global.EXECUTION_DATETIME = new Date(); + + /* Time Frames Definitions. */ + + global.marketFilesPeriods = + '[' + + '[' + 24 * 60 * 60 * 1000 + ',' + '"24-hs"' + ']' + ',' + + '[' + 12 * 60 * 60 * 1000 + ',' + '"12-hs"' + ']' + ',' + + '[' + 8 * 60 * 60 * 1000 + ',' + '"08-hs"' + ']' + ',' + + '[' + 6 * 60 * 60 * 1000 + ',' + '"06-hs"' + ']' + ',' + + '[' + 4 * 60 * 60 * 1000 + ',' + '"04-hs"' + ']' + ',' + + '[' + 3 * 60 * 60 * 1000 + ',' + '"03-hs"' + ']' + ',' + + '[' + 2 * 60 * 60 * 1000 + ',' + '"02-hs"' + ']' + ',' + + '[' + 1 * 60 * 60 * 1000 + ',' + '"01-hs"' + ']' + ']'; + + global.marketFilesPeriods = JSON.parse(global.marketFilesPeriods); + + global.dailyFilePeriods = + '[' + + '[' + 45 * 60 * 1000 + ',' + '"45-min"' + ']' + ',' + + '[' + 40 * 60 * 1000 + ',' + '"40-min"' + ']' + ',' + + '[' + 30 * 60 * 1000 + ',' + '"30-min"' + ']' + ',' + + '[' + 20 * 60 * 1000 + ',' + '"20-min"' + ']' + ',' + + '[' + 15 * 60 * 1000 + ',' + '"15-min"' + ']' + ',' + + '[' + 10 * 60 * 1000 + ',' + '"10-min"' + ']' + ',' + + '[' + 05 * 60 * 1000 + ',' + '"05-min"' + ']' + ',' + + '[' + 04 * 60 * 1000 + ',' + '"04-min"' + ']' + ',' + + '[' + 03 * 60 * 1000 + ',' + '"03-min"' + ']' + ',' + + '[' + 02 * 60 * 1000 + ',' + '"02-min"' + ']' + ',' + + '[' + 01 * 60 * 1000 + ',' + '"01-min"' + ']' + ']'; + + global.dailyFilePeriods = JSON.parse(global.dailyFilePeriods); + + global.ROOT_DIR = './'; + + global.ONE_YEAR_IN_MILISECONDS = 365 * 24 * 60 * 60 * 1000 + global.ONE_DAY_IN_MILISECONDS = 24 * 60 * 60 * 1000 + global.ONE_MIN_IN_MILISECONDS = 60 * 1000 + global.LOGGER_MAP = new Map() // We will put all the loggers in a map, so that we can eventually finalize them. + global.SESSION_MAP = new Map() // We will put all the sessions in a map, so that we can eventually finalize them. + + global.UNIQUE_ID = function () { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8) + return v.toString(16) + }) + } + + global.PRECISE = function (floatNumber, precision) { + return this.parseFloat(floatNumber.toFixed(precision)) + } + + global.REMOVE_TIME = function (datetime) { + const GMT_SECONDS = ':00.000 GMT+0000'; + let date = new Date(datetime) + return new Date(date.getUTCFullYear() + "-" + (date.getUTCMonth() + 1) + "-" + date.getUTCDate() + " " + "00:00" + GMT_SECONDS); + } + + global.PROCESS_ERROR = function (processKey, node, errorMessage) { + let event + if (node !== undefined) { + event = { + nodeName: node.name, + nodeType: node.type, + nodeId: node.id, + errorMessage: errorMessage + } + } else { + event = { + errorMessage: errorMessage + } + } + global.EVENT_SERVER_CLIENT.raiseEvent(processKey, 'Error', event) + } + + global.PROCESS_WARNING = function (processKey, node, warningMessage) { + let event + if (node !== undefined) { + event = { + nodeName: node.name, + nodeType: node.type, + nodeId: node.id, + warningMessage: warningMessage + } + } else { + event = { + warningMessage: warningMessage + } + } + global.EVENT_SERVER_CLIENT.raiseEvent(processKey, 'Warning', event) + } + + global.PROCESS_INFO = function (processKey, node, infoMessage) { + let event + if (node !== undefined) { + event = { + nodeName: node.name, + nodeType: node.type, + nodeId: node.id, + infoMessage: infoMessage + } + } else { + event = { + infoMessage: infoMessage + } + } + global.EVENT_SERVER_CLIENT.raiseEvent(processKey, 'Info', event) + } + + global.NODE_BRANCH_TO_ARRAY = function (node, nodeType) { + let resultArray = [] + scanNodeBranch(node, nodeType) + return resultArray + + function scanNodeBranch(startingNode) { + let nodeDefinition = global.APP_SCHEMA_MAP.get(startingNode.type) + if (nodeDefinition === undefined) { return } + + if (startingNode.type === nodeType) { + resultArray.push(startingNode) + return + } + + if (nodeDefinition.properties === undefined) { return } + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + + switch (property.type) { + case 'node': { + scanNodeBranch(startingNode[property.name]) + } + break + case 'array': { + let startingNodePropertyArray = startingNode[property.name] + if (startingNodePropertyArray !== undefined) { + for (let m = 0; m < startingNodePropertyArray.length; m++) { + scanNodeBranch(startingNodePropertyArray[m]) + } + } + break + } + } + } + } + } + + global.FIND_NODE_IN_NODE_MESH = function (node, nodeType) { + /* + This function scans a node mesh for a certain node type and + returns the first instance found. + */ + let nodeFound + scanNodeMesh(node, nodeType) + return nodeFound + + function scanNodeMesh(startingNode) { + if (startingNode === undefined) { return } + if (nodeFound !== undefined) { return } + + let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type) + if (nodeDefinition === undefined) { return } + + if (startingNode.type === nodeType) { + nodeFound = startingNode + return + } + + /* We scan through this node children */ + if (nodeDefinition.properties !== undefined) { + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + + switch (property.type) { + case 'node': { + scanNodeMesh(startingNode[property.name]) + } + break + case 'array': { + let startingNodePropertyArray = startingNode[property.name] + if (startingNodePropertyArray !== undefined) { + for (let m = 0; m < startingNodePropertyArray.length; m++) { + scanNodeMesh(startingNodePropertyArray[m]) + } + } + break + } + } + } + } + /* We scan parents nodes. */ + if (startingNode.parentNode !== undefined) { + scanNodeMesh(startingNode.parentNode) + } + /* We scan reference parents too. */ + if (startingNode.referenceParent !== undefined) { + scanNodeMesh(startingNode.referenceParent) + } + } + } + + global.NODE_MESH_TO_PATH_ARRAY = function (node, nodeId) { + /* + This function scans a node mesh for a certain node if and + returns an array with the path within that mesh to the + requested node. + */ + let nodeArray = [] + scanNodeMesh(node) + return nodeArray + + function scanNodeMesh(startingNode) { + if (startingNode === undefined) { return } + + let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type) + if (nodeDefinition === undefined) { return } + + if (startingNode.id === nodeId) { + nodeArray.push(startingNode) + return + } + + /* We scan through this node children */ + if (nodeDefinition.properties !== undefined) { + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + + switch (property.type) { + case 'node': { + scanNodeMesh(startingNode[property.name]) + if (nodeArray.length > 0) { + nodeArray.unshift(startingNode) + return + } + } + break + case 'array': { + let startingNodePropertyArray = startingNode[property.name] + if (startingNodePropertyArray !== undefined) { + for (let m = 0; m < startingNodePropertyArray.length; m++) { + scanNodeMesh(startingNodePropertyArray[m]) + if (nodeArray.length > 0) { + nodeArray.unshift(startingNode) + return + } + } + } + break + } + } + } + } + /* We scan parents nodes. */ + if (startingNode.parentNode !== undefined) { + scanNodeMesh(startingNode.parentNode) + if (nodeArray.length > 0) { + nodeArray.unshift(startingNode) + return + } + } + /* We scan reference parents too. */ + if (startingNode.referenceParent !== undefined) { + scanNodeMesh(startingNode.referenceParent) + if (nodeArray.length > 0) { + nodeArray.unshift(startingNode) + return + } + } + } + } + + global.FIND_NODE_IN_NODE_ARRAY = function (nodeArray, nodeType) { + for (let i = 0; i < nodeArray.length; i++) { + let node = nodeArray[i] + if (node.type === nodeType) { + return node + } + } + } + + global.FILTER_OUT_NODES_WITHOUT_REFERENCE_PARENT_FROM_NODE_ARRAY = function (nodeArray) { + let filteredNodeArray = [] + for (let i = 0; i < nodeArray.length; i++) { + let arrayItem = nodeArray[i] + if (arrayItem.referenceParent === undefined) { + continue + } else { + filteredNodeArray.push(arrayItem) + } + } + return filteredNodeArray + } + + global.EMIT_SESSION_STATUS = function (status, key) { + switch (status) { + case 'Running': { + global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Running') + break + } + case 'Stopped': { + global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Stopped') + break + } + } + } + } +} \ No newline at end of file diff --git a/TaskServer/Root.js b/TaskServer/Root.js index 7aa875fa5..76babbdd0 100644 --- a/TaskServer/Root.js +++ b/TaskServer/Root.js @@ -1,64 +1,15 @@ exports.newRoot = function newRoot() { - /* This is the Execution Datetime */ - - global.EXECUTION_DATETIME = new Date(); - - /* Time Frames Definitions. */ - - global.marketFilesPeriods = - '[' + - '[' + 24 * 60 * 60 * 1000 + ',' + '"24-hs"' + ']' + ',' + - '[' + 12 * 60 * 60 * 1000 + ',' + '"12-hs"' + ']' + ',' + - '[' + 8 * 60 * 60 * 1000 + ',' + '"08-hs"' + ']' + ',' + - '[' + 6 * 60 * 60 * 1000 + ',' + '"06-hs"' + ']' + ',' + - '[' + 4 * 60 * 60 * 1000 + ',' + '"04-hs"' + ']' + ',' + - '[' + 3 * 60 * 60 * 1000 + ',' + '"03-hs"' + ']' + ',' + - '[' + 2 * 60 * 60 * 1000 + ',' + '"02-hs"' + ']' + ',' + - '[' + 1 * 60 * 60 * 1000 + ',' + '"01-hs"' + ']' + ']'; - - global.marketFilesPeriods = JSON.parse(global.marketFilesPeriods); - - global.dailyFilePeriods = - '[' + - '[' + 45 * 60 * 1000 + ',' + '"45-min"' + ']' + ',' + - '[' + 40 * 60 * 1000 + ',' + '"40-min"' + ']' + ',' + - '[' + 30 * 60 * 1000 + ',' + '"30-min"' + ']' + ',' + - '[' + 20 * 60 * 1000 + ',' + '"20-min"' + ']' + ',' + - '[' + 15 * 60 * 1000 + ',' + '"15-min"' + ']' + ',' + - '[' + 10 * 60 * 1000 + ',' + '"10-min"' + ']' + ',' + - '[' + 05 * 60 * 1000 + ',' + '"05-min"' + ']' + ',' + - '[' + 04 * 60 * 1000 + ',' + '"04-min"' + ']' + ',' + - '[' + 03 * 60 * 1000 + ',' + '"03-min"' + ']' + ',' + - '[' + 02 * 60 * 1000 + ',' + '"02-min"' + ']' + ',' + - '[' + 01 * 60 * 1000 + ',' + '"01-min"' + ']' + ']'; - - global.dailyFilePeriods = JSON.parse(global.dailyFilePeriods); - const MODULE_NAME = "Root"; const WAIT_TIME_FOR_ALL_PROCESS_INSTANCES_TO_START = 10000 // This avoid a race condition that could happen if one process finished before all the other even started. let thisObject = { - initialize: initialize, start: start } - const FULL_LOG = true; - let logDisplace = "Task Server" + " "; - return thisObject; - function initialize(callBackFunction) { - try { - callBackFunction(); - } - catch (err) { - console.log(logDisplace + "Root : [ERROR] initialize -> err = " + err.stack); - return; - } - } - function start(processIndex) { try { /* Process Loops Declarations. */ @@ -279,8 +230,6 @@ global.LOGGER_MAP.set('runSensorBot', logger) logger.bot = pBotConfig; - if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> bootingBot -> runSensorBot -> Entering function."); } - let sensorBot = SENSOR_BOT.newSensorBot(pBotConfig, logger); sensorBot.initialize(pProcessConfig, onInitializeReady); @@ -341,8 +290,6 @@ global.LOGGER_MAP.set('runIndicatorBot', logger) logger.bot = pBotConfig; - if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> bootingBot -> runIndicatorBot -> Entering function."); } - let indicatorBot = INDICATOR_BOT_MODULE.newIndicatorBot(pBotConfig, logger); indicatorBot.initialize(pProcessConfig, onInitializeReady); @@ -404,8 +351,6 @@ global.LOGGER_MAP.set('runTradingBot', logger) logger.bot = pBotConfig; - if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> bootingBot -> runTradingBot -> Entering function."); } - let tradingBot = TRADING_BOT_MODULE.newTradingBot(pBotConfig, logger); tradingBot.initialize(pProcessConfig, onInitializeReady); @@ -469,8 +414,6 @@ global.LOGGER_MAP.set('runLearningBot', logger) logger.bot = pBotConfig; - if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> bootingBot -> runLearningBot -> Entering function."); } - let learningBot = TRADING_BOT_MODULE.newLearningBot(pBotConfig, logger); learningBot.initialize(pProcessConfig, onInitializeReady); diff --git a/TaskServer/server.js b/TaskServer/server.js index e693dcad8..18eeba400 100644 --- a/TaskServer/server.js +++ b/TaskServer/server.js @@ -1,301 +1,6 @@ - -/* Callbacks default responses. */ -global.DEFAULT_OK_RESPONSE = { - result: "Ok", - message: "Operation Succeeded" -}; - -global.DEFAULT_FAIL_RESPONSE = { - result: "Fail", - message: "Operation Failed" -}; - -global.DEFAULT_RETRY_RESPONSE = { - result: "Retry", - message: "Retry Later" -}; - -global.CUSTOM_OK_RESPONSE = { - result: "Ok, but check Message", - message: "Custom Message" -}; - -global.CUSTOM_FAIL_RESPONSE = { - result: "Fail Because", - message: "Custom Message" -}; - -global.ROOT_DIR = './'; - -global.ONE_YEAR_IN_MILISECONDS = 365 * 24 * 60 * 60 * 1000 -global.ONE_DAY_IN_MILISECONDS = 24 * 60 * 60 * 1000 -global.ONE_MIN_IN_MILISECONDS = 60 * 1000 -global.LOGGER_MAP = new Map() // We will put all the loggers in a map, so that we can eventually finalize them. -global.SESSION_MAP = new Map() // We will put all the sessions in a map, so that we can eventually finalize them. - -global.UNIQUE_ID = function () { - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { - var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8) - return v.toString(16) - }) -} - -global.PRECISE = function (floatNumber, precision) { - return this.parseFloat(floatNumber.toFixed(precision)) -} - -global.REMOVE_TIME = function (datetime) { - const GMT_SECONDS = ':00.000 GMT+0000'; - let date = new Date(datetime) - return new Date(date.getUTCFullYear() + "-" + (date.getUTCMonth() + 1) + "-" + date.getUTCDate() + " " + "00:00" + GMT_SECONDS); -} - -global.PROCESS_ERROR = function (processKey, node, errorMessage) { - let event - if (node !== undefined) { - event = { - nodeName: node.name, - nodeType: node.type, - nodeId: node.id, - errorMessage: errorMessage - } - } else { - event = { - errorMessage: errorMessage - } - } - global.EVENT_SERVER_CLIENT.raiseEvent(processKey, 'Error', event) -} - -global.PROCESS_WARNING = function (processKey, node, warningMessage) { - let event - if (node !== undefined) { - event = { - nodeName: node.name, - nodeType: node.type, - nodeId: node.id, - warningMessage: warningMessage - } - } else { - event = { - warningMessage: warningMessage - } - } - global.EVENT_SERVER_CLIENT.raiseEvent(processKey, 'Warning', event) -} - -global.PROCESS_INFO = function (processKey, node, infoMessage) { - let event - if (node !== undefined) { - event = { - nodeName: node.name, - nodeType: node.type, - nodeId: node.id, - infoMessage: infoMessage - } - } else { - event = { - infoMessage: infoMessage - } - } - global.EVENT_SERVER_CLIENT.raiseEvent(processKey, 'Info', event) -} - -global.NODE_BRANCH_TO_ARRAY = function (node, nodeType) { - let resultArray = [] - scanNodeBranch(node, nodeType) - return resultArray - - function scanNodeBranch(startingNode) { - let nodeDefinition = global.APP_SCHEMA_MAP.get(startingNode.type) - if (nodeDefinition === undefined) { return } - - if (startingNode.type === nodeType) { - resultArray.push(startingNode) - return - } - - if (nodeDefinition.properties === undefined) { return } - for (let i = 0; i < nodeDefinition.properties.length; i++) { - let property = nodeDefinition.properties[i] - - switch (property.type) { - case 'node': { - scanNodeBranch(startingNode[property.name]) - } - break - case 'array': { - let startingNodePropertyArray = startingNode[property.name] - if (startingNodePropertyArray !== undefined) { - for (let m = 0; m < startingNodePropertyArray.length; m++) { - scanNodeBranch(startingNodePropertyArray[m]) - } - } - break - } - } - } - } -} - -global.FIND_NODE_IN_NODE_MESH = function (node, nodeType) { - /* - This function scans a node mesh for a certain node type and - returns the first instance found. - */ - let nodeFound - scanNodeMesh(node, nodeType) - return nodeFound - - function scanNodeMesh(startingNode) { - if (startingNode === undefined) { return } - if (nodeFound !== undefined) { return } - - let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type) - if (nodeDefinition === undefined) { return } - - if (startingNode.type === nodeType) { - nodeFound = startingNode - return - } - - /* We scan through this node children */ - if (nodeDefinition.properties !== undefined) { - for (let i = 0; i < nodeDefinition.properties.length; i++) { - let property = nodeDefinition.properties[i] - - switch (property.type) { - case 'node': { - scanNodeMesh(startingNode[property.name]) - } - break - case 'array': { - let startingNodePropertyArray = startingNode[property.name] - if (startingNodePropertyArray !== undefined) { - for (let m = 0; m < startingNodePropertyArray.length; m++) { - scanNodeMesh(startingNodePropertyArray[m]) - } - } - break - } - } - } - } - /* We scan parents nodes. */ - if (startingNode.parentNode !== undefined) { - scanNodeMesh(startingNode.parentNode) - } - /* We scan reference parents too. */ - if (startingNode.referenceParent !== undefined) { - scanNodeMesh(startingNode.referenceParent) - } - } -} - -global.NODE_MESH_TO_PATH_ARRAY = function (node, nodeId) { - /* - This function scans a node mesh for a certain node if and - returns an array with the path within that mesh to the - requested node. - */ - let nodeArray = [] - scanNodeMesh(node) - return nodeArray - - function scanNodeMesh(startingNode) { - if (startingNode === undefined) { return } - - let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type) - if (nodeDefinition === undefined) { return } - - if (startingNode.id === nodeId) { - nodeArray.push(startingNode) - return - } - - /* We scan through this node children */ - if (nodeDefinition.properties !== undefined) { - for (let i = 0; i < nodeDefinition.properties.length; i++) { - let property = nodeDefinition.properties[i] - - switch (property.type) { - case 'node': { - scanNodeMesh(startingNode[property.name]) - if (nodeArray.length > 0) { - nodeArray.unshift(startingNode) - return - } - } - break - case 'array': { - let startingNodePropertyArray = startingNode[property.name] - if (startingNodePropertyArray !== undefined) { - for (let m = 0; m < startingNodePropertyArray.length; m++) { - scanNodeMesh(startingNodePropertyArray[m]) - if (nodeArray.length > 0) { - nodeArray.unshift(startingNode) - return - } - } - } - break - } - } - } - } - /* We scan parents nodes. */ - if (startingNode.parentNode !== undefined) { - scanNodeMesh(startingNode.parentNode) - if (nodeArray.length > 0) { - nodeArray.unshift(startingNode) - return - } - } - /* We scan reference parents too. */ - if (startingNode.referenceParent !== undefined) { - scanNodeMesh(startingNode.referenceParent) - if (nodeArray.length > 0) { - nodeArray.unshift(startingNode) - return - } - } - } -} - -global.FIND_NODE_IN_NODE_ARRAY = function (nodeArray, nodeType) { - for (let i=0; i < nodeArray.length; i++) { - let node = nodeArray[i] - if (node.type === nodeType) { - return node - } - } -} - -global.FILTER_OUT_NODES_WITHOUT_REFERENCE_PARENT_FROM_NODE_ARRAY = function (nodeArray) { - let filteredNodeArray = [] - for (let i = 0; i < nodeArray.length; i++) { - let arrayItem = nodeArray[i] - if (arrayItem.referenceParent === undefined) { - continue - } else { - filteredNodeArray.push(arrayItem) - } - } - return filteredNodeArray -} - -global.EMIT_SESSION_STATUS = function (status, key) { - switch(status) { - case 'Running': { - global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Running') - break - } - case 'Stopped': { - global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Stopped') - break - } - } -} +let GLOBALS = require('./Globals.js'); +let GLOBALS_MODULE = GLOBALS.newGlobals() +GLOBALS_MODULE.initialize() process.on('uncaughtException', function (err) { console.log('[ERROR] Task Server -> server -> uncaughtException -> err.message = ' + err.message) @@ -380,7 +85,7 @@ global.EXIT_NODE_PROCESS = function exitProcess() { for (let i = 0; i < global.TASK_NODE.bot.processes.length; i++) { let config = global.TASK_NODE.bot.processes[i].config let process = global.TASK_NODE.bot.processes[i] - + let key = process.name + '-' + process.type + '-' + process.id global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Stopped') // Meaning Process Stopped } @@ -435,7 +140,7 @@ function preLoader() { global.TASK_NODE = JSON.parse(message.event.taskDefinition) global.TASK_NETWORK = JSON.parse(message.event.networkDefinition) bootLoader() - } catch(err) { + } catch (err) { console.log('[ERROR] Task Server -> server -> preLoader -> eventReceived -> ' + err.stack) } } @@ -455,8 +160,8 @@ function preLoader() { global.TASK_NODE = JSON.parse(message.event.taskDefinition) global.TASK_NETWORK = JSON.parse(message.event.networkDefinition) bootLoader() - - } catch(err) { + + } catch (err) { console.log('[ERROR] Task Server -> server -> preLoader -> startDebugging -> ' + err.stack) } } @@ -514,7 +219,7 @@ function bootLoader() { global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Error', event) } - + for (let processIndex = 0; processIndex < global.TASK_NODE.bot.processes.length; processIndex++) { let config = global.TASK_NODE.bot.processes[processIndex].config @@ -613,12 +318,7 @@ function startRoot(processIndex) { const ROOT_MODULE = require('./Root') let root = ROOT_MODULE.newRoot() - root.initialize(onInitialized) - - function onInitialized() { - //console.log('[INFO] Task Server -> server -> startRoot -> onInitialized -> Entering function. ') - root.start(processIndex) - } + root.start(processIndex) } global.getPercentage = function (fromDate, currentDate, lastDate) {