NodeJsFunctions
This commit is contained in:
1 parent
ac182a905d
commit
7fa7cb91d4
6 files changed
+50
-34
No files matched your search
@@ -28,36 +28,7 @@ exports.newGlobals = function () {
|
||||
|
||||
global.SHUTTING_DOWN_PROCESS = false
|
||||
|
||||
global.EXIT_NODE_PROCESS = function exitProcess() {
|
||||
|
||||
if (global.unexpectedError !== undefined) {
|
||||
TS.projects.superalgos.functionLibraries.taskFunctions.taskError(undefined, "An unexpected error caused the Task to stop.")
|
||||
}
|
||||
|
||||
if (global.SHUTTING_DOWN_PROCESS === true) { return }
|
||||
global.SHUTTING_DOWN_PROCESS = true
|
||||
|
||||
/* Signal that all sessions are stopping. */
|
||||
TS.projects.superalgos.functionLibraries.sessionFunctions.finalizeSessions()
|
||||
|
||||
/* Cleaning Before Exiting. */
|
||||
clearInterval(global.HEARTBEAT_INTERVAL_HANDLER)
|
||||
|
||||
if (global.TASK_NODE !== undefined) {
|
||||
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_MODULE.raiseEvent(key, 'Stopped') // Meaning Process Stopped
|
||||
}
|
||||
}
|
||||
|
||||
global.FINALIZE_LOGGERS()
|
||||
//console.log("[INFO] Task Server -> " + global.TASK_NODE.name + " -> EXIT_NODE_PROCESS -> Task Server will stop in 10 seconds.");
|
||||
|
||||
setTimeout(process.exit, 10000) // We will give 10 seconds to logs be written on file
|
||||
}
|
||||
|
||||
require('dotenv').config();
|
||||
|
||||
|
||||
@@ -12,14 +12,14 @@ exports.newNodeJsProcess = function newNodeJsProcess() {
|
||||
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()
|
||||
TS.projects.superalgos.functionLibraries.nodeJSFunctions.exitProcess()
|
||||
})
|
||||
|
||||
process.on('unhandledRejection', (reason, 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()
|
||||
TS.projects.superalgos.functionLibraries.nodeJSFunctions.exitProcess()
|
||||
})
|
||||
|
||||
process.on('exit', function (config) {
|
||||
|
||||
@@ -322,7 +322,7 @@
|
||||
//console.log("[INFO] Task Server -> " + global.TASK_NODE.name + " -> exitProcessInstance -> Process #" + global.ENDED_PROCESSES_COUNTER + " from " + global.TOTAL_PROCESS_INSTANCES_CREATED + " exiting.");
|
||||
|
||||
if (global.ENDED_PROCESSES_COUNTER === global.TOTAL_PROCESS_INSTANCES_CREATED) {
|
||||
global.EXIT_NODE_PROCESS()
|
||||
TS.projects.superalgos.functionLibraries.nodeJSFunctions.exitProcess()
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
Reference in new issue
Block a user