More to Globals
This commit is contained in:
1 parent
5d73304b6d
commit
cb61d888e1
2 files changed
+52
-51
No files matched your search
@@ -340,5 +340,57 @@ exports.newGlobals = function newGlobals() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
global.FINALIZE_LOGGERS = function () {
|
||||
global.LOGGER_MAP.forEach(forEachLogger)
|
||||
|
||||
function forEachLogger(logger) {
|
||||
if (logger !== undefined) {
|
||||
logger.finalize()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
global.FINALIZE_SESSIONS = function () {
|
||||
global.SESSION_MAP.forEach(forEachSession)
|
||||
|
||||
function forEachSession(session) {
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(session, 'Stopped')
|
||||
}
|
||||
}
|
||||
|
||||
global.SHUTTING_DOWN_PROCESS = false
|
||||
|
||||
global.EXIT_NODE_PROCESS = function exitProcess() {
|
||||
|
||||
if (global.unexpectedError !== undefined) {
|
||||
global.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. */
|
||||
global.FINALIZE_SESSIONS()
|
||||
|
||||
/* 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.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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user