not needed globals

This commit is contained in:
Luis Fernando Molina committed 2020-12-02 12:09:39 +01:00
1 parent 196d1fdc33
commit 9ba720aafb
2 files changed
+26 -42

No files matched your search

+25 -41
View File
@@ -35,8 +35,8 @@ function preLoader() {
function eventReceived(message) {
try {
setUpAppSchema(JSON.parse(message.event.projectSchemas))
global.TASK_NODE = JSON.parse(message.event.taskDefinition)
global.NETWORK_NODE = JSON.parse(message.event.networkDefinition)
TS.projects.superalgos.globals.taskConstants.TASK_NODE = JSON.parse(message.event.taskDefinition)
TS.projects.superalgos.globals.taskConstants.NETWORK_NODE = JSON.parse(message.event.networkDefinition)
bootingProcess()
} catch (err) {
console.log('[ERROR] Task Server -> Task -> preLoader -> eventReceived -> ' + err.stack)
@@ -64,8 +64,8 @@ function preLoader() {
function startDebugging(message) {
try {
setUpAppSchema(JSON.parse(message.event.projectSchemas))
global.TASK_NODE = JSON.parse(message.event.taskDefinition)
global.NETWORK_NODE = JSON.parse(message.event.networkDefinition)
TS.projects.superalgos.globals.taskConstants.TASK_NODE = JSON.parse(message.event.taskDefinition)
TS.projects.superalgos.globals.taskConstants.NETWORK_NODE = JSON.parse(message.event.networkDefinition)
bootingProcess()
} catch (err) {
@@ -80,58 +80,42 @@ function preLoader() {
function setUpAppSchema(projectSchemas) {
/* Setup the APP_SCHEMA_MAP based on the APP_SCHEMA_ARRAY */
global.APP_SCHEMA_MAP = new Map()
for (let i = 0; i < projectSchemas.length; i++) {
let project = projectSchemas[i]
for (let j = 0; j < project.schema.length; j++) {
let nodeDefinition = project.schema[j]
let key = project.name + '-' + nodeDefinition.type
global.APP_SCHEMA_MAP.set(key, nodeDefinition)
TS.projects.superalgos.globals.taskConstants.APP_SCHEMA_MAP.set(key, nodeDefinition)
}
}
}
}
function bootingProcess() {
try {
initializeTaskConstants()
initializeProjectDefinitionNode()
setupTaskHeartbeats()
function initializeTaskConstants() {
/*
These constants could not be initialized before since they are received via websockets.
*/
TS.projects.superalgos.globals.taskConstants.TASK_NODE = global.TASK_NODE
global.TASK_NODE = undefined
TS.projects.superalgos.globals.taskConstants.NETWORK_NODE = global.NETWORK_NODE
NETWORK_NODE = undefined
TS.projects.superalgos.globals.taskConstants.APP_SCHEMA_MAP = global.APP_SCHEMA_MAP
global.APP_SCHEMA_MAP = undefined
initializeProjectDefinitionNode()
function initializeProjectDefinitionNode() {
TS.projects.superalgos.globals.taskConstants.PROJECT_DEFINITION_NODE = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(TS.projects.superalgos.globals.taskConstants.TASK_NODE, 'Project Definition')
if (TS.projects.superalgos.globals.taskConstants.PROJECT_DEFINITION_NODE === undefined) {
console.log("[ERROR] Task Server -> Task -> bootingProcess -> Project Definition not found. ")
global.unexpectedError = 'Project Definition not found. Fatal Error, can not continue. Fix the problem and try again.'
TS.projects.superalgos.functionLibraries.nodeJSFunctions.exitProcess
throw ('Fatal Error')
}
if (TS.projects.superalgos.globals.taskConstants.PROJECT_DEFINITION_NODE.config.codeName === undefined) {
console.log("[ERROR] Task Server -> Task -> bootingProcess -> Project Definition with codeName undefined. ")
global.unexpectedError = 'Project Definition with codeName undefined. Fatal Error, can not continue. Fix the problem and try again.'
TS.projects.superalgos.functionLibraries.nodeJSFunctions.exitProcess
throw ('Fatal Error')
}
if (TS.projects.superalgos.globals.taskConstants.PROJECT_DEFINITION_NODE.config.codeName === '') {
console.log("[ERROR] Task Server -> Task -> bootingProcess -> Project Definition without codeName. ")
global.unexpectedError = 'Project Definition without codeName. Fatal Error, can not continue. Fix the problem and try again.'
TS.projects.superalgos.functionLibraries.nodeJSFunctions.exitProcess
throw ('Fatal Error')
}
function initializeProjectDefinitionNode() {
TS.projects.superalgos.globals.taskConstants.PROJECT_DEFINITION_NODE = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(TS.projects.superalgos.globals.taskConstants.TASK_NODE, 'Project Definition')
if (TS.projects.superalgos.globals.taskConstants.PROJECT_DEFINITION_NODE === undefined) {
console.log("[ERROR] Task Server -> Task -> bootingProcess -> Project Definition not found. ")
global.unexpectedError = 'Project Definition not found. Fatal Error, can not continue. Fix the problem and try again.'
TS.projects.superalgos.functionLibraries.nodeJSFunctions.exitProcess
throw ('Fatal Error')
}
if (TS.projects.superalgos.globals.taskConstants.PROJECT_DEFINITION_NODE.config.codeName === undefined) {
console.log("[ERROR] Task Server -> Task -> bootingProcess -> Project Definition with codeName undefined. ")
global.unexpectedError = 'Project Definition with codeName undefined. Fatal Error, can not continue. Fix the problem and try again.'
TS.projects.superalgos.functionLibraries.nodeJSFunctions.exitProcess
throw ('Fatal Error')
}
if (TS.projects.superalgos.globals.taskConstants.PROJECT_DEFINITION_NODE.config.codeName === '') {
console.log("[ERROR] Task Server -> Task -> bootingProcess -> Project Definition without codeName. ")
global.unexpectedError = 'Project Definition without codeName. Fatal Error, can not continue. Fix the problem and try again.'
TS.projects.superalgos.functionLibraries.nodeJSFunctions.exitProcess
throw ('Fatal Error')
}
}