More reorganizing
This commit is contained in:
1 parent
56b4c7dfae
commit
8bb14854b7
2 files changed
+38
-40
No files matched your search
@@ -392,5 +392,42 @@ exports.newGlobals = function newGlobals() {
|
||||
|
||||
setTimeout(process.exit, 10000) // We will give 10 seconds to logs be written on file
|
||||
}
|
||||
|
||||
require('dotenv').config();
|
||||
|
||||
global.WRITE_LOGS_TO_FILES = process.env.WRITE_LOGS_TO_FILES
|
||||
|
||||
/*
|
||||
We need to count how many process instances we deployd and how many of them have already finished their job, either
|
||||
because they just finished or because there was a request to stop the proceses. In this way, once we reach the
|
||||
amount of instances started, we can safelly destroy the rest of the objects running and let this nodejs process die.
|
||||
*/
|
||||
|
||||
global.ENDED_PROCESSES_COUNTER = 0
|
||||
global.TOTAL_PROCESS_INSTANCES_CREATED = 0
|
||||
|
||||
global.STOP_TASK_GRACEFULLY = false;
|
||||
|
||||
global.getPercentage = function (fromDate, currentDate, lastDate) {
|
||||
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
|
||||
}
|
||||
|
||||
global.areEqualDates = function (date1, date2) {
|
||||
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 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-40
@@ -6,24 +6,9 @@ let NODE_JS_PROCESS = require('./NodeJsProcess.js');
|
||||
let NODE_JS_PROCESS_MODULE = NODE_JS_PROCESS.newNodeJsProcess()
|
||||
NODE_JS_PROCESS_MODULE.initialize()
|
||||
|
||||
require('dotenv').config();
|
||||
|
||||
global.WRITE_LOGS_TO_FILES = process.env.WRITE_LOGS_TO_FILES
|
||||
|
||||
/*
|
||||
We need to count how many process instances we deployd and how many of them have already finished their job, either
|
||||
because they just finished or because there was a request to stop the proceses. In this way, once we reach the
|
||||
amount of instances started, we can safelly destroy the rest of the objects running and let this nodejs process die.
|
||||
*/
|
||||
|
||||
global.ENDED_PROCESSES_COUNTER = 0
|
||||
global.TOTAL_PROCESS_INSTANCES_CREATED = 0
|
||||
|
||||
/*
|
||||
|
||||
We read the first string sent as an argument when the process was created by the Task Manager. There we will find the information of the identity
|
||||
of this Task and know exactly what to run within this server instance.
|
||||
|
||||
*/
|
||||
let taskId = process.argv[2] // reading what comes as an argument of the nodejs process.
|
||||
|
||||
@@ -33,7 +18,6 @@ let EVENT_SERVER_CLIENT = require('./EventServerClient.js');
|
||||
|
||||
global.EVENT_SERVER_CLIENT_MODULE = EVENT_SERVER_CLIENT.newEventsServerClient()
|
||||
global.EVENT_SERVER_CLIENT_MODULE.initialize(preLoader)
|
||||
global.STOP_TASK_GRACEFULLY = false;
|
||||
|
||||
function preLoader() {
|
||||
if (taskId !== undefined) {
|
||||
@@ -228,27 +212,4 @@ function startRoot(processIndex) {
|
||||
let root = ROOT_MODULE.newRoot()
|
||||
|
||||
root.start(processIndex)
|
||||
}
|
||||
|
||||
global.getPercentage = function (fromDate, currentDate, lastDate) {
|
||||
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
|
||||
}
|
||||
|
||||
global.areEqualDates = function (date1, date2) {
|
||||
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 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user