Refactoring
This commit is contained in:
1 parent
e3c1156a43
commit
56b4c7dfae
15 files changed
+65
-65
No files matched your search
@@ -108,7 +108,7 @@ exports.newGlobals = function newGlobals() {
|
||||
errorMessage: errorMessage
|
||||
}
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(processKey, 'Error', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(processKey, 'Error', event)
|
||||
}
|
||||
|
||||
global.PROCESS_WARNING = function (processKey, node, warningMessage) {
|
||||
@@ -125,7 +125,7 @@ exports.newGlobals = function newGlobals() {
|
||||
warningMessage: warningMessage
|
||||
}
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(processKey, 'Warning', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(processKey, 'Warning', event)
|
||||
}
|
||||
|
||||
global.PROCESS_INFO = function (processKey, node, infoMessage) {
|
||||
@@ -142,7 +142,7 @@ exports.newGlobals = function newGlobals() {
|
||||
infoMessage: infoMessage
|
||||
}
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(processKey, 'Info', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(processKey, 'Info', event)
|
||||
}
|
||||
|
||||
global.NODE_BRANCH_TO_ARRAY = function (node, nodeType) {
|
||||
@@ -331,11 +331,11 @@ exports.newGlobals = function newGlobals() {
|
||||
global.EMIT_SESSION_STATUS = function (status, key) {
|
||||
switch (status) {
|
||||
case 'Running': {
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Running')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Running')
|
||||
break
|
||||
}
|
||||
case 'Stopped': {
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Stopped')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Stopped')
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -356,7 +356,7 @@ exports.newGlobals = function newGlobals() {
|
||||
global.SESSION_MAP.forEach(forEachSession)
|
||||
|
||||
function forEachSession(session) {
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(session, 'Stopped')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(session, 'Stopped')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ exports.newGlobals = function newGlobals() {
|
||||
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.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Stopped') // Meaning Process Stopped
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -762,14 +762,14 @@
|
||||
percentage: percentage,
|
||||
status: status
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.processKey, 'Heartbeat', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.processKey, 'Heartbeat', event)
|
||||
}
|
||||
|
||||
function processStopped() {
|
||||
if (global.unexpectedError !== undefined) {
|
||||
global.PROCESS_ERROR(bot.processKey, undefined, "An unexpected error caused the Process to stop.")
|
||||
} else {
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.processKey, 'Stopped')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.processKey, 'Stopped')
|
||||
}
|
||||
logger.persist();
|
||||
clearInterval(fixedTimeLoopIntervalHandle);
|
||||
|
||||
@@ -37,10 +37,10 @@ exports.newLearningSession = function newLearningSession(bot, parentLogger) {
|
||||
bot.sessionKey = bot.processNode.session.name + '-' + bot.processNode.session.type + '-' + bot.processNode.session.id
|
||||
global.SESSION_MAP.set(bot.sessionKey, bot.sessionKey)
|
||||
|
||||
global.EVENT_SERVER_CLIENT.listenToEvent(bot.sessionKey, 'Learning Session Status', undefined, bot.sessionKey, undefined, onSessionStatus)
|
||||
global.EVENT_SERVER_CLIENT.listenToEvent(bot.sessionKey, 'Run Learning Session', undefined, bot.sessionKey, undefined, onSessionRun)
|
||||
global.EVENT_SERVER_CLIENT.listenToEvent(bot.sessionKey, 'Stop Learning Session', undefined, bot.sessionKey, undefined, onSessionStop)
|
||||
global.EVENT_SERVER_CLIENT.listenToEvent(bot.sessionKey, 'Resume Learning Session', undefined, bot.sessionKey, undefined, onSessionResume)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.listenToEvent(bot.sessionKey, 'Learning Session Status', undefined, bot.sessionKey, undefined, onSessionStatus)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.listenToEvent(bot.sessionKey, 'Run Learning Session', undefined, bot.sessionKey, undefined, onSessionRun)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.listenToEvent(bot.sessionKey, 'Stop Learning Session', undefined, bot.sessionKey, undefined, onSessionStop)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.listenToEvent(bot.sessionKey, 'Resume Learning Session', undefined, bot.sessionKey, undefined, onSessionResume)
|
||||
|
||||
/* Connect this here so that it is accesible from other places */
|
||||
bot.sessionError = sessionError
|
||||
@@ -58,12 +58,12 @@ exports.newLearningSession = function newLearningSession(bot, parentLogger) {
|
||||
let event = {
|
||||
status: 'Learning Session Runnning'
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.sessionKey, 'Status Response', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.sessionKey, 'Status Response', event)
|
||||
} else {
|
||||
let event = {
|
||||
status: 'Learning Session Not Runnning'
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.sessionKey, 'Status Response', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.sessionKey, 'Status Response', event)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ exports.newLearningSession = function newLearningSession(bot, parentLogger) {
|
||||
percentage: percentage,
|
||||
status: status
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.sessionKey, 'Heartbeat', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.sessionKey, 'Heartbeat', event)
|
||||
|
||||
if (global.STOP_TASK_GRACEFULLY === true) {
|
||||
bot.STOP_SESSION = true
|
||||
@@ -458,7 +458,7 @@ exports.newLearningSession = function newLearningSession(bot, parentLogger) {
|
||||
errorMessage: errorMessage
|
||||
}
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.sessionKey, 'Error', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.sessionKey, 'Error', event)
|
||||
|
||||
if (global.STOP_TASK_GRACEFULLY === true) {
|
||||
bot.STOP_SESSION = true
|
||||
@@ -480,7 +480,7 @@ exports.newLearningSession = function newLearningSession(bot, parentLogger) {
|
||||
warningMessage: warningMessage
|
||||
}
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.sessionKey, 'Warning', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.sessionKey, 'Warning', event)
|
||||
|
||||
if (global.STOP_TASK_GRACEFULLY === true) {
|
||||
bot.STOP_SESSION = true
|
||||
@@ -502,7 +502,7 @@ exports.newLearningSession = function newLearningSession(bot, parentLogger) {
|
||||
infoMessage: infoMessage
|
||||
}
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.sessionKey, 'Info', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.sessionKey, 'Info', event)
|
||||
|
||||
if (global.STOP_TASK_GRACEFULLY === true) {
|
||||
bot.STOP_SESSION = true
|
||||
|
||||
@@ -669,7 +669,7 @@
|
||||
dateRange: dataRange
|
||||
}
|
||||
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Data Range Updated', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Data Range Updated', event)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -508,7 +508,7 @@
|
||||
dateRange: dataRange
|
||||
}
|
||||
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Data Range Updated', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Data Range Updated', event)
|
||||
writeTimeFramesFile(productCodeName, callBack)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ exports.newNodeJsProcess = function newNodeJsProcess() {
|
||||
/* We send an event signaling that the Task is being terminated. */
|
||||
let key = global.TASK_NODE.name + '-' + global.TASK_NODE.type + '-' + global.TASK_NODE.id
|
||||
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Stopped') // Meaning Task Stopped
|
||||
global.EVENT_SERVER_CLIENT.finalize()
|
||||
global.EVENT_SERVER_CLIENT = undefined
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Stopped') // Meaning Task Stopped
|
||||
global.EVENT_SERVER_CLIENT_MODULE.finalize()
|
||||
global.EVENT_SERVER_CLIENT_MODULE = undefined
|
||||
}
|
||||
|
||||
//console.log('[INFO] Task Server -> server -> process.on.exit -> About to exit -> config = ' + config)
|
||||
|
||||
@@ -231,8 +231,8 @@
|
||||
let event = {
|
||||
err: global.DEFAULT_OK_RESPONSE
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.createEventHandler(currentProcessKey, 'Process Execution Started')
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(currentProcessKey, 'Process Execution Started', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.createEventHandler(currentProcessKey, 'Process Execution Started')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(currentProcessKey, 'Process Execution Started', event)
|
||||
|
||||
bot.processHeartBeat(undefined, undefined, "Running...")
|
||||
|
||||
@@ -247,8 +247,8 @@
|
||||
let event = {
|
||||
err: global.DEFAULT_OK_RESPONSE
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.createEventHandler(currentProcessKey, 'Process Execution Started')
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(currentProcessKey, 'Process Execution Started', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.createEventHandler(currentProcessKey, 'Process Execution Started')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(currentProcessKey, 'Process Execution Started', event)
|
||||
|
||||
logger.write(MODULE_NAME, "[INFO] start -> " + currentProcessKey + " Process Execution Started ")
|
||||
|
||||
@@ -271,8 +271,8 @@
|
||||
err: global.DEFAULT_OK_RESPONSE
|
||||
}
|
||||
|
||||
global.EVENT_SERVER_CLIENT.createEventHandler(currentProcessKey, 'Process Execution Finished')
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(currentProcessKey, 'Process Execution Finished', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.createEventHandler(currentProcessKey, 'Process Execution Finished')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(currentProcessKey, 'Process Execution Finished', event)
|
||||
|
||||
logger.write(MODULE_NAME, "[INFO] finish -> " + currentProcessKey + " Process Execution Finished ")
|
||||
|
||||
|
||||
@@ -94,8 +94,8 @@
|
||||
lastFile: lastFile,
|
||||
timeFrames: timeFrames
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.createEventHandler(key, 'Dataset Updated')
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Dataset Updated', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.createEventHandler(key, 'Dataset Updated')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Dataset Updated', event)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,8 +176,8 @@
|
||||
lastFile: lastFile,
|
||||
timeFrames: timeFrames
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.createEventHandler(key, 'Dataset Updated')
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Dataset Updated', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.createEventHandler(key, 'Dataset Updated')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Dataset Updated', event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -534,7 +534,7 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) {
|
||||
logger.persist();
|
||||
}
|
||||
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.sessionKey, 'Stopped')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.sessionKey, 'Stopped')
|
||||
processStopped()
|
||||
return;
|
||||
}
|
||||
@@ -648,14 +648,14 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) {
|
||||
percentage: percentage,
|
||||
status: status
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.processKey, 'Heartbeat', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.processKey, 'Heartbeat', event)
|
||||
}
|
||||
|
||||
function processStopped() {
|
||||
if (global.unexpectedError !== undefined) {
|
||||
global.PROCESS_ERROR(bot.processKey, undefined, "An unexpected error caused the Process to stop.")
|
||||
} else {
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.processKey, 'Stopped')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.processKey, 'Stopped')
|
||||
}
|
||||
sessionStopped()
|
||||
logger.persist();
|
||||
@@ -670,7 +670,7 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) {
|
||||
|
||||
function sessionStopped() {
|
||||
if (bot.SESSION_STATUS === 'Running') {
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.sessionKey, 'Stopped')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.sessionKey, 'Stopped')
|
||||
bot.SESSION_STATUS = 'Stopped'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -669,7 +669,7 @@ exports.newLearningProcess = function newLearningProcess(bot, logger, UTILITIES)
|
||||
dateRange: dataRange
|
||||
}
|
||||
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Data Range Updated', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Data Range Updated', event)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -571,14 +571,14 @@
|
||||
percentage: percentage,
|
||||
status: status
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.processKey, 'Heartbeat', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.processKey, 'Heartbeat', event)
|
||||
}
|
||||
|
||||
function processStopped() {
|
||||
if (global.unexpectedError !== undefined) {
|
||||
global.PROCESS_ERROR(bot.processKey, undefined, "An unexpected error caused the Process to stop.")
|
||||
} else {
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.processKey, 'Stopped')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.processKey, 'Stopped')
|
||||
}
|
||||
logger.persist();
|
||||
clearInterval(fixedTimeLoopIntervalHandle);
|
||||
|
||||
@@ -534,7 +534,7 @@
|
||||
logger.persist();
|
||||
}
|
||||
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.TRADING_SESSIONKey, 'Stopped')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.TRADING_SESSIONKey, 'Stopped')
|
||||
processStopped()
|
||||
return;
|
||||
}
|
||||
@@ -648,14 +648,14 @@
|
||||
percentage: percentage,
|
||||
status: status
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.processKey, 'Heartbeat', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.processKey, 'Heartbeat', event)
|
||||
}
|
||||
|
||||
function processStopped() {
|
||||
if (global.unexpectedError !== undefined) {
|
||||
global.PROCESS_ERROR(bot.processKey, undefined, "An unexpected error caused the Process to stop.")
|
||||
} else {
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.processKey, 'Stopped')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.processKey, 'Stopped')
|
||||
}
|
||||
sessionStopped()
|
||||
logger.persist();
|
||||
@@ -670,7 +670,7 @@
|
||||
|
||||
function sessionStopped() {
|
||||
if (bot.TRADING_SESSION_STATUS === 'Running') {
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.TRADING_SESSIONKey, 'Stopped')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.TRADING_SESSIONKey, 'Stopped')
|
||||
bot.TRADING_SESSION_STATUS = 'Stopped'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,10 +37,10 @@
|
||||
bot.TRADING_SESSIONKey = bot.processNode.session.name + '-' + bot.processNode.session.type + '-' + bot.processNode.session.id
|
||||
global.SESSION_MAP.set(bot.TRADING_SESSIONKey, bot.TRADING_SESSIONKey)
|
||||
|
||||
global.EVENT_SERVER_CLIENT.listenToEvent(bot.TRADING_SESSIONKey, 'Trading Session Status', undefined, bot.TRADING_SESSIONKey, undefined, onSessionStatus)
|
||||
global.EVENT_SERVER_CLIENT.listenToEvent(bot.TRADING_SESSIONKey, 'Run Trading Session', undefined, bot.TRADING_SESSIONKey, undefined, onSessionRun)
|
||||
global.EVENT_SERVER_CLIENT.listenToEvent(bot.TRADING_SESSIONKey, 'Stop Trading Session', undefined, bot.TRADING_SESSIONKey, undefined, onSessionStop)
|
||||
global.EVENT_SERVER_CLIENT.listenToEvent(bot.TRADING_SESSIONKey, 'Resume Trading Session', undefined, bot.TRADING_SESSIONKey, undefined, onSessionResume)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.listenToEvent(bot.TRADING_SESSIONKey, 'Trading Session Status', undefined, bot.TRADING_SESSIONKey, undefined, onSessionStatus)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.listenToEvent(bot.TRADING_SESSIONKey, 'Run Trading Session', undefined, bot.TRADING_SESSIONKey, undefined, onSessionRun)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.listenToEvent(bot.TRADING_SESSIONKey, 'Stop Trading Session', undefined, bot.TRADING_SESSIONKey, undefined, onSessionStop)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.listenToEvent(bot.TRADING_SESSIONKey, 'Resume Trading Session', undefined, bot.TRADING_SESSIONKey, undefined, onSessionResume)
|
||||
|
||||
/* Connect this here so that it is accesible from other places */
|
||||
bot.TRADING_SESSIONError = sessionError
|
||||
@@ -58,12 +58,12 @@
|
||||
let event = {
|
||||
status: 'Trading Session Runnning'
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.TRADING_SESSIONKey, 'Status Response', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.TRADING_SESSIONKey, 'Status Response', event)
|
||||
} else {
|
||||
let event = {
|
||||
status: 'Trading Session Not Runnning'
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.TRADING_SESSIONKey, 'Status Response', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.TRADING_SESSIONKey, 'Status Response', event)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@
|
||||
percentage: percentage,
|
||||
status: status
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.TRADING_SESSIONKey, 'Heartbeat', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.TRADING_SESSIONKey, 'Heartbeat', event)
|
||||
|
||||
if (global.STOP_TASK_GRACEFULLY === true) {
|
||||
bot.STOP_SESSION = true
|
||||
@@ -458,7 +458,7 @@
|
||||
errorMessage: errorMessage
|
||||
}
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.TRADING_SESSIONKey, 'Error', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.TRADING_SESSIONKey, 'Error', event)
|
||||
|
||||
if (global.STOP_TASK_GRACEFULLY === true) {
|
||||
bot.STOP_SESSION = true
|
||||
@@ -480,7 +480,7 @@
|
||||
warningMessage: warningMessage
|
||||
}
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.TRADING_SESSIONKey, 'Warning', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.TRADING_SESSIONKey, 'Warning', event)
|
||||
|
||||
if (global.STOP_TASK_GRACEFULLY === true) {
|
||||
bot.STOP_SESSION = true
|
||||
@@ -502,7 +502,7 @@
|
||||
infoMessage: infoMessage
|
||||
}
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(bot.TRADING_SESSIONKey, 'Info', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.TRADING_SESSIONKey, 'Info', event)
|
||||
|
||||
if (global.STOP_TASK_GRACEFULLY === true) {
|
||||
bot.STOP_SESSION = true
|
||||
|
||||
@@ -31,8 +31,8 @@ let taskId = process.argv[2] // reading what comes as an argument of the nodejs
|
||||
|
||||
let EVENT_SERVER_CLIENT = require('./EventServerClient.js');
|
||||
|
||||
global.EVENT_SERVER_CLIENT = EVENT_SERVER_CLIENT.newEventsServerClient()
|
||||
global.EVENT_SERVER_CLIENT.initialize(preLoader)
|
||||
global.EVENT_SERVER_CLIENT_MODULE = EVENT_SERVER_CLIENT.newEventsServerClient()
|
||||
global.EVENT_SERVER_CLIENT_MODULE.initialize(preLoader)
|
||||
global.STOP_TASK_GRACEFULLY = false;
|
||||
|
||||
function preLoader() {
|
||||
@@ -40,8 +40,8 @@ function preLoader() {
|
||||
/* The Task Manager sent the info via a process argument. In this case we listen to an event with the Task Info that should be emitted at the UI */
|
||||
try {
|
||||
//console.log('[INFO] Task Server -> server -> preLoader -> Listening to starting event -> key = ' + 'Task Server - ' + taskId)
|
||||
global.EVENT_SERVER_CLIENT.listenToEvent('Task Server - ' + taskId, 'Run Task', undefined, 'Task Server - ' + taskId, undefined, eventReceived)
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent('Task Manager - ' + taskId, 'Nodejs Process Ready for Task')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.listenToEvent('Task Server - ' + taskId, 'Run Task', undefined, 'Task Server - ' + taskId, undefined, eventReceived)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent('Task Manager - ' + taskId, 'Nodejs Process Ready for Task')
|
||||
function eventReceived(message) {
|
||||
try {
|
||||
global.APP_SCHEMA_ARRAY = JSON.parse(message.event.appSchema)
|
||||
@@ -61,7 +61,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 {
|
||||
//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)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.listenToEvent('Task Server', 'Debug Task Started', undefined, 'Task Server', undefined, startDebugging)
|
||||
function startDebugging(message) {
|
||||
try {
|
||||
global.APP_SCHEMA_ARRAY = JSON.parse(message.event.appSchema)
|
||||
@@ -97,8 +97,8 @@ function bootLoader() {
|
||||
|
||||
let key = global.TASK_NODE.name + '-' + global.TASK_NODE.type + '-' + global.TASK_NODE.id
|
||||
|
||||
global.EVENT_SERVER_CLIENT.createEventHandler(key)
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Running') // Meaning Task Running
|
||||
global.EVENT_SERVER_CLIENT_MODULE.createEventHandler(key)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Running') // Meaning Task Running
|
||||
global.HEARTBEAT_INTERVAL_HANDLER = setInterval(taskHearBeat, 1000)
|
||||
|
||||
function taskHearBeat() {
|
||||
@@ -107,7 +107,7 @@ function bootLoader() {
|
||||
let event = {
|
||||
seconds: (new Date()).getSeconds()
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Heartbeat', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Heartbeat', event)
|
||||
}
|
||||
|
||||
global.taskError = function taskError(node, errorMessage) {
|
||||
@@ -125,7 +125,7 @@ function bootLoader() {
|
||||
}
|
||||
}
|
||||
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Error', event)
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Error', event)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user