Beta 6 without Execution
This commit is contained in:
1 parent
4033d4d07f
commit
d40b985f5e
123 files changed
+8114
-12392
No files matched your search
+47
-21
@@ -25,7 +25,11 @@ global.CUSTOM_FAIL_RESPONSE = {
|
||||
message: "Custom Message"
|
||||
};
|
||||
|
||||
const ONE_DAY_IN_MILISECONDS = 24 * 60 * 60 * 1000;
|
||||
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()
|
||||
global.SESSION_MAP = new Map()
|
||||
|
||||
@@ -57,7 +61,7 @@ function finalizeSessions() {
|
||||
}
|
||||
}
|
||||
|
||||
process.on('exit', function (code) {
|
||||
process.on('exit', function (config) {
|
||||
|
||||
if (global.TASK_NODE !== undefined) {
|
||||
/* We send an event signaling that the Task is being terminated. */
|
||||
@@ -68,7 +72,7 @@ process.on('exit', function (code) {
|
||||
global.EVENT_SERVER_CLIENT = undefined
|
||||
}
|
||||
|
||||
//console.log('[INFO] Task Server -> server -> process.on.exit -> About to exit -> code = ' + code)
|
||||
//console.log('[INFO] Task Server -> server -> 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. */
|
||||
@@ -84,13 +88,17 @@ process.on('message', message => {
|
||||
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.')
|
||||
setTimeout(global.EXIT_NODE_PROCESS, 60000);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
let shuttingDownProcess = false
|
||||
global.EXIT_NODE_PROCESS = function exitProcess() {
|
||||
|
||||
if (global.unexpectedError !== undefined) {
|
||||
global.taskError(undefined, "An unexpected error caused the Task to stop.")
|
||||
}
|
||||
|
||||
if (shuttingDownProcess === true) { return }
|
||||
shuttingDownProcess = true
|
||||
|
||||
@@ -101,7 +109,7 @@ global.EXIT_NODE_PROCESS = function exitProcess() {
|
||||
clearInterval(global.HEARTBEAT_INTERVAL_HANDLER)
|
||||
|
||||
for (let i = 0; i < global.TASK_NODE.bot.processes.length; i++) {
|
||||
let code = global.TASK_NODE.bot.processes[i].code
|
||||
let config = global.TASK_NODE.bot.processes[i].config
|
||||
let process = global.TASK_NODE.bot.processes[i]
|
||||
|
||||
key = process.name + '-' + process.type + '-' + process.id
|
||||
@@ -138,7 +146,7 @@ let taskId = process.argv[2] // reading what comes as an argument of the nodejs
|
||||
/* Setting up the global Event Handler */
|
||||
|
||||
let EVENT_SERVER_CLIENT = require('./EventServerClient.js');
|
||||
|
||||
|
||||
global.EVENT_SERVER_CLIENT = EVENT_SERVER_CLIENT.newEventsServerClient()
|
||||
global.EVENT_SERVER_CLIENT.initialize(preLoader)
|
||||
global.STOP_TASK_GRACEFULLY = false;
|
||||
@@ -162,7 +170,7 @@ function preLoader() {
|
||||
}
|
||||
}
|
||||
else { /* This process was started not by the Task Manager, but independently (most likely for debugging purposes). In this case we listen to an event with the Task Info that should be emitted at the UI */
|
||||
try {
|
||||
try {
|
||||
//console.log('[INFO] Task Server -> server -> preLoader -> Waiting for event to start debugging...')
|
||||
global.EVENT_SERVER_CLIENT.listenToEvent('Task Server', 'Debug Task Started', undefined, 'Task Server', undefined, startDebugging)
|
||||
function startDebugging(message) {
|
||||
@@ -190,15 +198,33 @@ function bootLoader() {
|
||||
|
||||
function taskHearBeat() {
|
||||
|
||||
/* The heartbeat event is raised at the event handler of the instance of this task, created at the UI. */
|
||||
/* The heartbeat event is raised at the event handler of the instance of this task, created at the UI. */
|
||||
let event = {
|
||||
seconds: (new Date()).getSeconds()
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Heartbeat', event)
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Heartbeat', event)
|
||||
}
|
||||
|
||||
global.taskError = function taskError(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(key, 'Error', event)
|
||||
}
|
||||
|
||||
for (let processIndex = 0; processIndex < global.TASK_NODE.bot.processes.length; processIndex++) {
|
||||
let code = global.TASK_NODE.bot.processes[processIndex].code
|
||||
let config = global.TASK_NODE.bot.processes[processIndex].config
|
||||
|
||||
/* Validate that the minimun amount of input required are defined. */
|
||||
|
||||
@@ -257,17 +283,17 @@ function bootLoader() {
|
||||
continue
|
||||
}
|
||||
|
||||
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.code.codeName === undefined) {
|
||||
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName === undefined) {
|
||||
console.log("[WARN] Task Server -> server -> 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.code.codeName === undefined) {
|
||||
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.codeName === undefined) {
|
||||
console.log("[WARN] Task Server -> server -> 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.code.codeName === undefined) {
|
||||
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName === undefined) {
|
||||
console.log("[WARN] Task Server -> server -> bootLoader -> Data Mine without a codeName defined. -> Data Mine Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode));
|
||||
continue
|
||||
}
|
||||
@@ -278,7 +304,7 @@ function bootLoader() {
|
||||
|
||||
function startRoot(processIndex) {
|
||||
|
||||
// console.log('[INFO] Task Server -> server -> startRoot -> Entering function. ')
|
||||
// console.log('[INFO] Task Server -> server -> startRoot -> Entering function. ')
|
||||
|
||||
const ROOT_MODULE = require('./Root')
|
||||
let root = ROOT_MODULE.newRoot()
|
||||
@@ -292,20 +318,20 @@ function startRoot(processIndex) {
|
||||
}
|
||||
|
||||
global.getPercentage = function (fromDate, currentDate, lastDate) {
|
||||
let fromDays = Math.trunc(fromDate.valueOf() / ONE_DAY_IN_MILISECONDS)
|
||||
let currentDays = Math.trunc(currentDate.valueOf() / ONE_DAY_IN_MILISECONDS)
|
||||
let lastDays = Math.trunc(lastDate.valueOf() / ONE_DAY_IN_MILISECONDS)
|
||||
let fromDays = Math.trunc(fromDate.valueOf() / global.ONE_DAY_IN_MILISECONDS)
|
||||
let currentDays = Math.trunc(currentDate.valueOf() / global.ONE_DAY_IN_MILISECONDS)
|
||||
let lastDays = Math.trunc(lastDate.valueOf() / global.ONE_DAY_IN_MILISECONDS)
|
||||
let percentage = (currentDays - fromDays) * 100 / (lastDays - fromDays)
|
||||
if ((lastDays - fromDays) === 0) {
|
||||
percentage = 100
|
||||
}
|
||||
return percentage
|
||||
return percentage
|
||||
}
|
||||
|
||||
global.areEqualDates = function (date1, date2) {
|
||||
let day1Days = Math.trunc(date1.valueOf() / ONE_DAY_IN_MILISECONDS)
|
||||
let day2Days = Math.trunc(date2.valueOf() / ONE_DAY_IN_MILISECONDS)
|
||||
|
||||
let day1Days = Math.trunc(date1.valueOf() / global.ONE_DAY_IN_MILISECONDS)
|
||||
let day2Days = Math.trunc(date2.valueOf() / global.ONE_DAY_IN_MILISECONDS)
|
||||
|
||||
if (day1Days === day2Days) {
|
||||
return true
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user