From 94afd3eb386f0ed80cf0d530372cd116df63358c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 6 Apr 2020 08:07:22 +0200 Subject: [PATCH] Remove IPC, using Web Sockets now --- SystemEventHandler.js => EventServerClient.js | 133 +++++++++--------- IndicatorBotProcessMainLoop.js | 4 +- MultiPeriod.js | 2 +- MultiPeriodDaily.js | 2 +- ProcessExecutionEvents.js | 16 +-- ProcessOutput.js | 4 +- Project.njsproj | 2 +- SensorBotProcessMainLoop.js | 4 +- Session.js | 4 +- TradingBotProcessMainLoop.js | 14 +- package-lock.json | 38 +---- package.json | 4 +- server.js | 36 ++--- 13 files changed, 119 insertions(+), 144 deletions(-) rename SystemEventHandler.js => EventServerClient.js (57%) diff --git a/SystemEventHandler.js b/EventServerClient.js similarity index 57% rename from SystemEventHandler.js rename to EventServerClient.js index 6071dbfea..8450b3bb4 100644 --- a/SystemEventHandler.js +++ b/EventServerClient.js @@ -1,6 +1,8 @@ -exports.newSystemEventHandler = function newSystemEventHandler(ipc) { +exports.newEventsServerClient = function newEventsServerClient() { - const MODULE = "Task Server -> System Event Handler -> " + const MODULE = "Task Server " + const ERROR_LOG = true + const INFO_LOG = false let thisObject = { initialize: initialize, @@ -15,74 +17,72 @@ let eventListeners = new Map() let responseWaiters = new Map() - ipc.config.id = 'Task Server'; - ipc.config.retry = 1500; - ipc.config.silent = true; + let WEB_SOCKETS_CLIENT + const WEB_SOCKET = require('ws') + let port = process.env.WEB_SOCKETS_SERVER_PORT return thisObject - function initialize(canllerName, callBackFunction) { + function initialize(callBackFunction) { - ipc.connectTo( - 'world', - function () { - ipc.of.world.on( - 'connect', - function () { - ipc.log(MODULE + '## Connected to Superalgos Event Server ##'.rainbow, ipc.config.delay); + setuptWebSockets(callBackFunction) - let eventCommand = { - action: 'greetings', - from: canllerName - } + } - sendCommand(eventCommand) + function setuptWebSockets(callBackFunction) { + try { - callBackFunction() - } - ); - ipc.of.world.on( - 'disconnect', - function () { - ipc.log(MODULE + 'Disconnected from Superalgos Event Server '.notice); - } - ); - ipc.of.world.on( - 'message', // here is where all incomming messages are processed. - function (data) { - ipc.log('Got a message from Superalgos Event Server: '.debug, data); - - let message = JSON.parse(data) + WEB_SOCKETS_CLIENT = new WEB_SOCKET('ws://localhost:' + port ) - if (message.action === 'Event Raised') { - - let key - if (message.callerId) { - key = message.eventHandlerName + '-' + message.eventType + '-' + message.callerId - } else { - key = message.eventHandlerName + '-' + message.eventType - } - let handler = eventListeners.get(key) - if (handler) { - handler.callBack(message) - } else { - console.log(MODULE + key + ' not found so could not deliver event raised.') - console.log(MODULE + ' Message = ' + data) - } - return - } - - if (message.action === 'Event Server Response') { - let handler = responseWaiters.get(message.callerId) - if (handler) { - handler(message) - } - return - } - } - ); + WEB_SOCKETS_CLIENT.onerror = error => { + console.log('[ERROR] Task Server -> Event Server Client -> setuptWebSockets -> On connection error -> error = ' + JSON.stringify(error)) } - ); + WEB_SOCKETS_CLIENT.onopen = () => { + if (INFO_LOG === true) { + console.log('Websocket connection opened.') + } + + if (callBackFunction !== undefined) { + callBackFunction() + } + } + WEB_SOCKETS_CLIENT.onmessage = e => { + + try { + if (INFO_LOG === true) { + console.log('Websocket Message Received: ' + e.data) + } + + let message = JSON.parse(e.data) + + if (message.action === 'Event Raised') { + let key + if (message.callerId !== undefined) { + key = message.eventHandlerName + '-' + message.eventType + '-' + message.callerId + } else { + key = message.eventHandlerName + '-' + message.eventType + } + let handler = eventListeners.get(key) + if (handler) { + handler.callBack(message) + } + return + } + + if (message.action === 'Event Server Response') { + let handler = responseWaiters.get(message.callerId) + if (handler) { + handler(message) + } + return + } + } catch (err) { + if (ERROR_LOG === true) { logger.write('[ERROR] Task Server -> Event Server Client -> setuptWebSockets -> onmessage -> err = ' + err.stack) } + } + } + } catch (err) { + if (ERROR_LOG === true) { logger.write('[ERROR] Task Server -> Event Server Client -> setuptWebSockets -> err = ' + err.stack) } + } } function finalize() { @@ -98,7 +98,7 @@ } sendCommand(eventCommand) } - ipc.disconnect('world'); + WEB_SOCKETS_CLIENT.disconnect(); } function sendCommand(command, responseCallBack, eventsCallBack) { @@ -122,10 +122,11 @@ responseWaiters.set(command.callerId, responseCallBack) } - ipc.of.world.emit( - 'message', - JSON.stringify(command) - ) + if (WEB_SOCKETS_CLIENT.readyState === 1) { // 1 means connected and ready. + WEB_SOCKETS_CLIENT.send("Task Server||" + JSON.stringify(command)) + } else { + console.log('[ERROR] Task Server -> Event Server Client -> setuptWebSockets -> sendCommand -> WebSocket message could not be sent because the connection was not ready. Message = ' + JSON.stringify(command)) + } } function createEventHandler(eventHandlerName, callerId, responseCallBack) { diff --git a/IndicatorBotProcessMainLoop.js b/IndicatorBotProcessMainLoop.js index a99c9e97b..d24bf9bf9 100644 --- a/IndicatorBotProcessMainLoop.js +++ b/IndicatorBotProcessMainLoop.js @@ -1088,11 +1088,11 @@ percentage: percentage, status: status } - global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.processKey, 'Heartbeat', event) + global.EVENT_SERVER_CLIENT.raiseEvent(bot.processKey, 'Heartbeat', event) } function processStopped() { - global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.processKey, 'Stopped') + global.EVENT_SERVER_CLIENT.raiseEvent(bot.processKey, 'Stopped') } } catch (err) { diff --git a/MultiPeriod.js b/MultiPeriod.js index 09d54057a..67ed3d365 100644 --- a/MultiPeriod.js +++ b/MultiPeriod.js @@ -1009,7 +1009,7 @@ dateRange: dataRange } - global.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Data Range Updated', event) + global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Data Range Updated', event) callBack(global.DEFAULT_OK_RESPONSE); } diff --git a/MultiPeriodDaily.js b/MultiPeriodDaily.js index 516737d4c..01850e771 100644 --- a/MultiPeriodDaily.js +++ b/MultiPeriodDaily.js @@ -787,7 +787,7 @@ dateRange: dataRange } - global.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Data Range Updated', event) + global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Data Range Updated', event) callBack(global.DEFAULT_OK_RESPONSE); } diff --git a/ProcessExecutionEvents.js b/ProcessExecutionEvents.js index 72741eba4..18ff8a70b 100644 --- a/ProcessExecutionEvents.js +++ b/ProcessExecutionEvents.js @@ -81,7 +81,7 @@ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] start -> waitForDependantProcess -> key = " + key); } if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] start -> waitForDependantProcess -> callerId = " + callerId); } - global.SYSTEM_EVENT_HANDLER.listenToEvent(key, 'Process Execution Finished', undefined, callerId, responseCallBack, eventsCallBack) + global.EVENT_SERVER_CLIENT.listenToEvent(key, 'Process Execution Finished', undefined, callerId, responseCallBack, eventsCallBack) bot.processHeartBeat(undefined, undefined, "Waiting for " + processThisDependsOn.parentNode.parentNode.name + "->" + processThisDependsOn.parentNode.code.codeName + "->" + processThisDependsOn.code.codeName) @@ -102,15 +102,15 @@ /* We continue the normal flow after we learn the dependent process has finished its execution. */ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] start -> eventsCallBack -> stopListening to Process Execution Finished. "); } if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] start -> eventsCallBack -> subscriptionId = " + subscriptionId); } - global.SYSTEM_EVENT_HANDLER.stopListening(key, 'Process Execution Finished', subscriptionId) + global.EVENT_SERVER_CLIENT.stopListening(key, 'Process Execution Finished', subscriptionId) if (message.event.err.result === global.DEFAULT_OK_RESPONSE.result) { /* We emit our own event that the process started. */ let event = { err: global.DEFAULT_OK_RESPONSE } - global.SYSTEM_EVENT_HANDLER.createEventHandler(currentProcessKey, 'Process Execution Started') - global.SYSTEM_EVENT_HANDLER.raiseEvent(currentProcessKey, 'Process Execution Started', event) + global.EVENT_SERVER_CLIENT.createEventHandler(currentProcessKey, 'Process Execution Started') + global.EVENT_SERVER_CLIENT.raiseEvent(currentProcessKey, 'Process Execution Started', event) bot.processHeartBeat(undefined, undefined,"Running...") @@ -125,8 +125,8 @@ let event = { err: global.DEFAULT_OK_RESPONSE } - global.SYSTEM_EVENT_HANDLER.createEventHandler(currentProcessKey, 'Process Execution Started') - global.SYSTEM_EVENT_HANDLER.raiseEvent(currentProcessKey, 'Process Execution Started', event) + global.EVENT_SERVER_CLIENT.createEventHandler(currentProcessKey, 'Process Execution Started') + global.EVENT_SERVER_CLIENT.raiseEvent(currentProcessKey, 'Process Execution Started', event) if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] start -> " + currentProcessKey + " Process Execution Started " ); } @@ -149,8 +149,8 @@ err: global.DEFAULT_OK_RESPONSE } - global.SYSTEM_EVENT_HANDLER.createEventHandler(currentProcessKey, 'Process Execution Finished') - global.SYSTEM_EVENT_HANDLER.raiseEvent(currentProcessKey, 'Process Execution Finished', event) + global.EVENT_SERVER_CLIENT.createEventHandler(currentProcessKey, 'Process Execution Finished') + global.EVENT_SERVER_CLIENT.raiseEvent(currentProcessKey, 'Process Execution Finished', event) if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] finish -> " + currentProcessKey + " Process Execution Finished " ); } diff --git a/ProcessOutput.js b/ProcessOutput.js index 4d2369ece..7bbdfff10 100644 --- a/ProcessOutput.js +++ b/ProcessOutput.js @@ -85,8 +85,8 @@ let event = { lastFile: lastFile } - global.SYSTEM_EVENT_HANDLER.createEventHandler(key, 'Dataset Updated') - global.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Dataset Updated', event) + global.EVENT_SERVER_CLIENT.createEventHandler(key, 'Dataset Updated') + global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Dataset Updated', event) } } diff --git a/Project.njsproj b/Project.njsproj index 79e2bba93..c4bad9883 100644 --- a/Project.njsproj +++ b/Project.njsproj @@ -51,7 +51,7 @@ Code - + Code diff --git a/SensorBotProcessMainLoop.js b/SensorBotProcessMainLoop.js index f73961f20..dbcc04b3f 100644 --- a/SensorBotProcessMainLoop.js +++ b/SensorBotProcessMainLoop.js @@ -810,11 +810,11 @@ percentage: percentage, status: status } - global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.processKey, 'Heartbeat', event) + global.EVENT_SERVER_CLIENT.raiseEvent(bot.processKey, 'Heartbeat', event) } function processStopped() { - global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.processKey, 'Stopped') + global.EVENT_SERVER_CLIENT.raiseEvent(bot.processKey, 'Stopped') } } diff --git a/Session.js b/Session.js index 0d6685f89..1a15af6d8 100644 --- a/Session.js +++ b/Session.js @@ -38,8 +38,8 @@ /* Listen to event to start or stop the session. */ bot.sessionKey = bot.processNode.session.name + '-' + bot.processNode.session.type + '-' + bot.processNode.session.id - global.SYSTEM_EVENT_HANDLER.listenToEvent(bot.sessionKey, 'Run Session', undefined, undefined, undefined, runSession) - global.SYSTEM_EVENT_HANDLER.listenToEvent(bot.sessionKey, 'Stop Session', undefined, undefined, undefined, stopSession) + global.EVENT_SERVER_CLIENT.listenToEvent(bot.sessionKey, 'Run Session', undefined, undefined, undefined, runSession) + global.EVENT_SERVER_CLIENT.listenToEvent(bot.sessionKey, 'Stop Session', undefined, undefined, undefined, stopSession) callBackFunction(global.DEFAULT_OK_RESPONSE) return diff --git a/TradingBotProcessMainLoop.js b/TradingBotProcessMainLoop.js index 3820e6d33..81fb60613 100644 --- a/TradingBotProcessMainLoop.js +++ b/TradingBotProcessMainLoop.js @@ -164,12 +164,12 @@ /* Checking if we need to need to emit any event */ if (bot.SESSION_STATUS === 'Idle' && bot.STOP_SESSION === false) { - global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.sessionKey, 'Running') + global.EVENT_SERVER_CLIENT.raiseEvent(bot.sessionKey, 'Running') bot.SESSION_STATUS = 'Running' } if (bot.SESSION_STATUS === 'Running' && bot.STOP_SESSION === true) { - global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.sessionKey, 'Stopped') + global.EVENT_SERVER_CLIENT.raiseEvent(bot.sessionKey, 'Stopped') bot.SESSION_STATUS = 'Stopped' } @@ -880,7 +880,7 @@ logger.persist(); } - global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.sessionKey, 'Stopped') + global.EVENT_SERVER_CLIENT.raiseEvent(bot.sessionKey, 'Stopped') processStopped() callBackFunction(global.DEFAULT_OK_RESPONSE); return; @@ -1013,7 +1013,7 @@ percentage: percentage, status: status } - global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.processKey, 'Heartbeat', event) + global.EVENT_SERVER_CLIENT.raiseEvent(bot.processKey, 'Heartbeat', event) } function sessionHeartBeat(processingDate) { @@ -1021,7 +1021,7 @@ seconds: (new Date()).getSeconds(), processingDate: processingDate } - global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.sessionKey, 'Heartbeat', event) + global.EVENT_SERVER_CLIENT.raiseEvent(bot.sessionKey, 'Heartbeat', event) if (global.STOP_TASK_GRACEFULLY === true) { bot.STOP_SESSION = true @@ -1029,12 +1029,12 @@ } function processStopped() { - global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.processKey, 'Stopped') + global.EVENT_SERVER_CLIENT.raiseEvent(bot.processKey, 'Stopped') } function sessionStopped() { if (bot.SESSION_STATUS === 'Running') { - global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.sessionKey, 'Stopped') + global.EVENT_SERVER_CLIENT.raiseEvent(bot.sessionKey, 'Stopped') bot.SESSION_STATUS = 'Stopped' } } diff --git a/package-lock.json b/package-lock.json index 3c66c72d6..9da031d46 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,29 +22,6 @@ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==" }, - "easy-stack": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/easy-stack/-/easy-stack-1.0.0.tgz", - "integrity": "sha1-EskbMIWjfwuqM26UhurEv5Tj54g=" - }, - "event-pubsub": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/event-pubsub/-/event-pubsub-4.3.0.tgz", - "integrity": "sha512-z7IyloorXvKbFx9Bpie2+vMJKKx1fH1EN5yiTfp8CiLOTptSYy1g8H4yDpGlEdshL1PBiFtBHepF2cNsqeEeFQ==" - }, - "js-message": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/js-message/-/js-message-1.0.5.tgz", - "integrity": "sha1-IwDSSxrwjondCVvBpMnJz8uJLRU=" - }, - "js-queue": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/js-queue/-/js-queue-2.0.0.tgz", - "integrity": "sha1-NiITz4YPRo8BJfxslqvBdCUx+Ug=", - "requires": { - "easy-stack": "1.0.0" - } - }, "minimist": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", @@ -65,16 +42,6 @@ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" }, - "node-ipc": { - "version": "9.1.1", - "resolved": "https://registry.npmjs.org/node-ipc/-/node-ipc-9.1.1.tgz", - "integrity": "sha512-FAyICv0sIRJxVp3GW5fzgaf9jwwRQxAKDJlmNFUL5hOy+W4X/I5AypyHoq0DXXbo9o/gt79gj++4cMr4jVWE/w==", - "requires": { - "event-pubsub": "4.3.0", - "js-message": "1.0.5", - "js-queue": "2.0.0" - } - }, "sandwich-stream": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/sandwich-stream/-/sandwich-stream-2.0.2.tgz", @@ -97,6 +64,11 @@ "version": "3.6.1", "resolved": "https://registry.npmjs.org/telegram-typings/-/telegram-typings-3.6.1.tgz", "integrity": "sha512-njVv1EAhIZnmQVLocZEADYUyqA1WIXuVcDYlsp+mXua/XB0pxx+PKtMSPeZ/EE4wPWTw9h/hA9ASTT6yQelkiw==" + }, + "ws": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.2.3.tgz", + "integrity": "sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ==" } } } diff --git a/package.json b/package.json index a44ed04e9..33f6c67e8 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "dependencies": { "ccxt": "^1.25.80", "dotenv": "^8.2.0", - "node-ipc": "^9.1.1", - "telegraf": "^3.37.0" + "telegraf": "^3.37.0", + "ws": "^7.1.2" } } diff --git a/server.js b/server.js index 566a26f89..4b813c954 100644 --- a/server.js +++ b/server.js @@ -40,13 +40,15 @@ process.on('unhandledRejection', (reason, p) => { }) process.on('exit', function (code) { - - /* 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.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Stopped') // Meaning Task Stopped - global.SYSTEM_EVENT_HANDLER.finalize() - global.SYSTEM_EVENT_HANDLER = undefined + if (global.TASK_NODE !== undefined) { + /* 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 + } //console.log('[INFO] Task Server -> server -> process.on.exit -> About to exit -> code = ' + code) }) @@ -77,7 +79,7 @@ global.EXIT_NODE_PROCESS = function exitProcess() { let process = global.TASK_NODE.bot.processes[i] key = process.name + '-' + process.type + '-' + process.id - global.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Stopped') // Meaning Process Stopped + global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Stopped') // Meaning Process Stopped } //console.log("[INFO] Task Server -> " + global.TASK_NODE.name + " -> EXIT_NODE_PROCESS -> Task Server will stop in 10 seconds."); @@ -108,10 +110,10 @@ let taskId = process.argv[2] // reading what comes as an argument of the nodejs /* Setting up the global Event Handler */ -const EVENT_HANDLER_MODULE = require('./SystemEventHandler.js'); -const IPC = require('node-ipc'); -global.SYSTEM_EVENT_HANDLER = EVENT_HANDLER_MODULE.newSystemEventHandler(IPC) -global.SYSTEM_EVENT_HANDLER.initialize('Task Server', preLoader) +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; function preLoader() { @@ -119,8 +121,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.SYSTEM_EVENT_HANDLER.listenToEvent('Task Server - ' + taskId, 'Run Task', undefined, undefined, undefined, eventReceived) - global.SYSTEM_EVENT_HANDLER.raiseEvent('Task Manager - ' + taskId, 'Nodejs Process Ready for Task') + global.EVENT_SERVER_CLIENT.listenToEvent('Task Server - ' + taskId, 'Run Task', undefined, undefined, undefined, eventReceived) + global.EVENT_SERVER_CLIENT.raiseEvent('Task Manager - ' + taskId, 'Nodejs Process Ready for Task') function eventReceived(message) { global.TASK_NODE = message global.TASK_NODE = JSON.parse(message.event.definition) @@ -134,7 +136,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.SYSTEM_EVENT_HANDLER.listenToEvent('Task Server', 'Debug Task Started', undefined, undefined, undefined, startDebugging) + global.EVENT_SERVER_CLIENT.listenToEvent('Task Server', 'Debug Task Started', undefined, undefined, undefined, startDebugging) function startDebugging(message) { global.TASK_NODE = message global.TASK_NODE = JSON.parse(message.event.definition) @@ -153,8 +155,8 @@ function bootLoader() { let key = global.TASK_NODE.name + '-' + global.TASK_NODE.type + '-' + global.TASK_NODE.id - global.SYSTEM_EVENT_HANDLER.createEventHandler(key) - global.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Running') // Meaning Task Running + global.EVENT_SERVER_CLIENT.createEventHandler(key) + global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Running') // Meaning Task Running global.HEARTBEAT_INTERVAL_HANDLER = setInterval(taskHearBeat, 1000) function taskHearBeat() { @@ -163,7 +165,7 @@ function bootLoader() { let event = { seconds: (new Date()).getSeconds() } - global.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Heartbeat', event) + global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Heartbeat', event) } for (let processIndex = 0; processIndex < global.TASK_NODE.bot.processes.length; processIndex++) {