More reorganizing

This commit is contained in:
Luis Fernando Molina committed 2020-11-25 17:02:33 +01:00
1 parent 93d9cd403e
commit 14f2058730
5 files changed
+33 -35

No files matched your search

+2 -2
View File
@@ -1,8 +1,8 @@
{
"name": "client",
"name": "Client",
"version": "0.0.6",
"description": "BackendServer",
"main": "server.js",
"main": "client.js",
"author": {
"name": "Luis-Fernando-Molina"
},
+1 -1
View File
@@ -64,7 +64,7 @@
//console.log('[INFO] Client -> Task Manager Server -> runTask -> Task Name = ' + message.event.taskName)
//console.log('[INFO] Client -> Task Manager Server -> runTask -> Task Id = ' + message.event.taskId)
let path = process.env.TASK_SERVER_PATH + '/server.js'
let path = process.env.TASK_SERVER_PATH + '/Task.js'
/* Workarround to avoid having the same debug port at the forked process which makes it crash. */
for (let i = 0; i < process.execArgv.length; i++) {
+1 -1
View File
@@ -11,7 +11,7 @@
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}\\server.js"
"program": "${workspaceFolder}\\Task.js"
}
]
}
+6 -6
View File
@@ -9,15 +9,15 @@ exports.newNodeJsProcess = function newNodeJsProcess() {
function initialize() {
process.on('uncaughtException', function (err) {
console.log('[ERROR] Task Server -> server -> uncaughtException -> err.message = ' + err.message)
console.log('[ERROR] Task Server -> server -> uncaughtException -> err.stack = ' + err.stack)
console.log('[ERROR] Task Server -> Node JS Process -> uncaughtException -> err.message = ' + err.message)
console.log('[ERROR] Task Server -> Node JS Process -> uncaughtException -> err.stack = ' + err.stack)
console.log(err.stack)
global.EXIT_NODE_PROCESS()
})
process.on('unhandledRejection', (reason, p) => {
console.log('[ERROR] Task Server -> server -> unhandledRejection -> reason = ' + JSON.stringify(reason))
console.log('[ERROR] Task Server -> server -> unhandledRejection -> p = ' + JSON.stringify(p))
console.log('[ERROR] Task Server -> Node JS Process -> unhandledRejection -> reason = ' + JSON.stringify(reason))
console.log('[ERROR] Task Server -> Node JS Process -> unhandledRejection -> p = ' + JSON.stringify(p))
console.log(reason.stack)
global.EXIT_NODE_PROCESS()
})
@@ -33,7 +33,7 @@ exports.newNodeJsProcess = function newNodeJsProcess() {
global.EVENT_SERVER_CLIENT_MODULE = undefined
}
//console.log('[INFO] Task Server -> server -> process.on.exit -> About to exit -> config = ' + config)
//console.log('[INFO] Task Server -> Node JS Process -> process.on.exit -> About to exit -> config = ' + config)
})
/* Here we listen for the message to stop this Task / Process comming from the Task Manager, which is the paret of this node js process. */
@@ -47,7 +47,7 @@ exports.newNodeJsProcess = function newNodeJsProcess() {
In order to be sure that the process will be terminated, we schedulle one forced exit in 2 minutes from now.
*/
let key = global.TASK_NODE.name + '-' + global.TASK_NODE.type + '-' + global.TASK_NODE.id
console.log('[INFO] Task Server -> server -> process.on -> Stopping Task ' + key + '. Nodejs process will be exited in less than 1 minute.')
console.log('[INFO] Task Server -> Node JS Process -> process.on -> Stopping Task ' + key + '. Nodejs process will be exited in less than 1 minute.')
setTimeout(global.EXIT_NODE_PROCESS, 60000);
}
});
+23 -25
View File
@@ -23,7 +23,7 @@ function preLoader() {
if (taskId !== undefined) {
/* The Task Manager sent the info via a process argument. In this case we listen to an event with the Task Info that should be emitted at the UI */
try {
//console.log('[INFO] Task Server -> server -> preLoader -> Listening to starting event -> key = ' + 'Task Server - ' + taskId)
//console.log('[INFO] Task Server -> Task -> preLoader -> Listening to starting event -> key = ' + 'Task Server - ' + taskId)
global.EVENT_SERVER_CLIENT_MODULE.listenToEvent('Task Server - ' + taskId, 'Run Task', undefined, 'Task Server - ' + taskId, undefined, eventReceived)
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent('Task Manager - ' + taskId, 'Nodejs Process Ready for Task')
function eventReceived(message) {
@@ -34,12 +34,12 @@ function preLoader() {
global.TASK_NETWORK = JSON.parse(message.event.networkDefinition)
bootLoader()
} catch (err) {
console.log('[ERROR] Task Server -> server -> preLoader -> eventReceived -> ' + err.stack)
console.log('[ERROR] Task Server -> Task -> preLoader -> eventReceived -> ' + err.stack)
}
}
} catch (err) {
console.log('[ERROR] Task Server -> server -> preLoader -> global.TASK_NODE -> ' + err.stack)
console.log('[ERROR] Task Server -> server -> preLoader -> global.TASK_NODE = ' + JSON.stringify(global.TASK_NODE).substring(0, 1000))
console.log('[ERROR] Task Server -> Task -> preLoader -> global.TASK_NODE -> ' + err.stack)
console.log('[ERROR] Task Server -> Task -> preLoader -> global.TASK_NODE = ' + JSON.stringify(global.TASK_NODE).substring(0, 1000))
}
}
else {
@@ -59,12 +59,12 @@ function preLoader() {
bootLoader()
} catch (err) {
console.log('[ERROR] Task Server -> server -> preLoader -> startDebugging -> ' + err.stack)
console.log('[ERROR] Task Server -> Task -> preLoader -> startDebugging -> ' + err.stack)
}
}
} catch (err) {
console.log('[ERROR] Task Server -> server -> preLoader -> global.TASK_NODE -> ' + err.stack)
console.log('[ERROR] Task Server -> server -> preLoader -> global.TASK_NODE = ' + JSON.stringify(global.TASK_NODE).substring(0, 1000))
console.log('[ERROR] Task Server -> Task -> preLoader -> global.TASK_NODE -> ' + err.stack)
console.log('[ERROR] Task Server -> Task -> preLoader -> global.TASK_NODE = ' + JSON.stringify(global.TASK_NODE).substring(0, 1000))
}
}
@@ -104,84 +104,84 @@ function bootLoader() {
/* Validate that the minimun amount of input required are defined. */
if (global.TASK_NODE.parentNode === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Task without a Task Manager. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex]));
console.log("[ERROR] Task Server -> Task -> bootLoader -> Task without a Task Manager. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex]));
continue
}
if (global.TASK_NODE.parentNode.parentNode === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Task Manager without Mine Tasks. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex]));
console.log("[ERROR] Task Server -> Task -> bootLoader -> Task Manager without Mine Tasks. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex]));
continue
}
if (global.TASK_NODE.parentNode.parentNode.parentNode === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Mine Tasks without Market Tasks. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex]));
console.log("[ERROR] Task Server -> Task -> bootLoader -> Mine Tasks without Market Tasks. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex]));
continue
}
if (global.TASK_NODE.parentNode.parentNode.parentNode.referenceParent === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Market Tasks without a Market. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex]));
console.log("[ERROR] Task Server -> Task -> bootLoader -> Market Tasks without a Market. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex]));
continue
}
global.MARKET_NODE = global.TASK_NODE.parentNode.parentNode.parentNode.referenceParent
if (global.MARKET_NODE.parentNode === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Market without a Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.MARKET_NODE));
console.log("[ERROR] Task Server -> Task -> bootLoader -> Market without a Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.MARKET_NODE));
continue
}
if (global.MARKET_NODE.parentNode.parentNode === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Exchange Markets without a Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.MARKET_NODE.parentNode));
console.log("[ERROR] Task Server -> Task -> bootLoader -> Exchange Markets without a Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.MARKET_NODE.parentNode));
continue
}
if (global.MARKET_NODE.baseAsset === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Market without a Base Asset. This process will not be executed. -> Process Instance = " + JSON.stringify(global.MARKET_NODE));
console.log("[ERROR] Task Server -> Task -> bootLoader -> Market without a Base Asset. This process will not be executed. -> Process Instance = " + JSON.stringify(global.MARKET_NODE));
continue
}
if (global.MARKET_NODE.quotedAsset === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Market without a Quoted Asset. This process will not be executed. -> Process Instance = " + JSON.stringify(global.MARKET_NODE));
console.log("[ERROR] Task Server -> Task -> bootLoader -> Market without a Quoted Asset. This process will not be executed. -> Process Instance = " + JSON.stringify(global.MARKET_NODE));
continue
}
if (global.MARKET_NODE.baseAsset.referenceParent === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Base Asset without a Reference Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.MARKET_NODE.baseAsset));
console.log("[ERROR] Task Server -> Task -> bootLoader -> Base Asset without a Reference Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.MARKET_NODE.baseAsset));
continue
}
if (global.MARKET_NODE.quotedAsset.referenceParent === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Quoted Asset without a Reference Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.MARKET_NODE.quotedAsset));
console.log("[ERROR] Task Server -> Task -> bootLoader -> Quoted Asset without a Reference Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.MARKET_NODE.quotedAsset));
continue
}
if (global.TASK_NODE.bot.processes[processIndex].referenceParent === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Process Instance without a Reference Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex]));
console.log("[ERROR] Task Server -> Task -> bootLoader -> Process Instance without a Reference Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex]));
continue
}
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Process Definition without parent Bot Definition. -> Process Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent));
console.log("[ERROR] Task Server -> Task -> bootLoader -> Process Definition without parent Bot Definition. -> Process Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent));
continue
}
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Bot Definition without parent Data Mine. -> Bot Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode));
console.log("[ERROR] Task Server -> Task -> bootLoader -> Bot Definition without parent Data Mine. -> Bot Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode));
continue
}
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Process Definition without a codeName defined. -> Process Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent));
console.log("[ERROR] Task Server -> Task -> bootLoader -> Process Definition without a codeName defined. -> Process Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent));
continue
}
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.codeName === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Bot Definition without a codeName defined. -> Bot Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode));
console.log("[ERROR] Task Server -> Task -> bootLoader -> Bot Definition without a codeName defined. -> Bot Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode));
continue
}
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName === undefined) {
console.log("[ERROR] Task Server -> server -> bootLoader -> Data Mine without a codeName defined. -> Data Mine Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode));
console.log("[ERROR] Task Server -> Task -> bootLoader -> Data Mine without a codeName defined. -> Data Mine Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode));
continue
}
@@ -191,8 +191,6 @@ function bootLoader() {
function startRoot(processIndex) {
// console.log('[INFO] Task Server -> server -> startRoot -> Entering function. ')
const ROOT_MODULE = require('./Root')
let root = ROOT_MODULE.newRoot()