From 411a8ca2d797f476c3129b6c6f700e5db578ce86 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 16 Nov 2020 10:26:11 +0100 Subject: [PATCH] Latest --- .env | 4 +- Client/httpInterface.js | 14 +++---- Client/server.js | 35 +++++++++++------- .../{webAppFileServer.js => uiFileServer.js} | 4 +- Client/webSocketsServer.js | 2 +- .../Check-Webhook/User.Bot.js | 2 +- TaskServer/EventServerClient.js | 2 +- run.js | 37 ++++++++++++++----- 8 files changed, 62 insertions(+), 38 deletions(-) rename Client/{webAppFileServer.js => uiFileServer.js} (69%) diff --git a/.env b/.env index 71f9a4193..7982f8e55 100644 --- a/.env +++ b/.env @@ -1,7 +1,7 @@ #PORT NUMBERS: If any of these ports are already in use by a different app, please pick a new number between 1 and 50000. -WEB_SERVER_PORT=34248 -WEB_SOCKETS_SERVER_PORT=18041 +HTTP_INTERFACE_PORT=34248 +WEB_SOCKETS_INTERFACE_PORT=18041 # TASK MANAGER VARIABLES: diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 1b61c268c..b6449a863 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -1,4 +1,4 @@ -exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVER, PROJECT_FILE_SERVER, WEB_APP_FILE_SERVER, PLUGIN_SERVER, CCXT_SERVER, WEB3_SERVER) { +exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVER, PROJECT_FILE_SERVER, UI_FILE_SERVER, PLUGIN_SERVER, CCXT_SERVER, WEB3_SERVER) { let thisObject = { initialize: initialize, @@ -13,7 +13,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE CONSOLE_ERROR_LOG = process.env.CONSOLE_ERROR_LOG === 'true' LOG_FILE_CONTENT = process.env.LOG_FILE_CONTENT === 'true' - let port = process.env.WEB_SERVER_PORT + let port = process.env.HTTP_INTERFACE_PORT let http = require('http') let isHttpServerStarted = false @@ -43,7 +43,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE isHttpServerStarted = true /* Starting the browser now is optional */ if (process.argv.includes("noBrowser")) { - console.log('Running Backend only with no UI.') + //Running Backend only with no UI. } else { open('http://localhost:' + port) } @@ -798,9 +798,9 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE try { let fileContent = file.toString() - fileContent = fileContent.replace('WEB_SERVER_PORT', process.env.WEB_SERVER_PORT) - fileContent = fileContent.replace('WEB_SERVER_PORT', process.env.WEB_SERVER_PORT) - fileContent = fileContent.replace('WEB_SERVER_PORT', process.env.WEB_SERVER_PORT) + fileContent = fileContent.replace('HTTP_INTERFACE_PORT', process.env.HTTP_INTERFACE_PORT) + fileContent = fileContent.replace('HTTP_INTERFACE_PORT', process.env.HTTP_INTERFACE_PORT) + fileContent = fileContent.replace('HTTP_INTERFACE_PORT', process.env.HTTP_INTERFACE_PORT) respondWithContent(fileContent, response, 'text/css') } catch (err) { console.log('[ERROR] httpInterface -> mainCSS -> File Not Found: ' + fileName + ' or Error = ' + err.stack) @@ -822,7 +822,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE try { let fileContent = file.toString() - fileContent = fileContent.replace('WEB_SERVER_PORT', process.env.WEB_SERVER_PORT) + fileContent = fileContent.replace('HTTP_INTERFACE_PORT', process.env.HTTP_INTERFACE_PORT) respondWithContent(fileContent, response) } catch (err) { console.log('[ERROR] httpInterface -> homePage -> File Not Found: ' + fileName + ' or Error = ' + err.stack) diff --git a/Client/server.js b/Client/server.js index 5e6256889..8f268c35e 100644 --- a/Client/server.js +++ b/Client/server.js @@ -46,7 +46,7 @@ global.CUSTOM_FAIL_RESPONSE = { let WEB_SERVER = require('./webServer.js') let DATA_FILE_SERVER = require('./dataFileServer.js') let PROJECT_FILE_SERVER = require('./projectFileServer.js') -let WEB_APP_FILE_SERVER = require('./webAppFileServer.js') +let UI_FILE_SERVER = require('./uiFileServer.js') let PLUGIN_SERVER = require('./pluginServer.js') let EVENT_SERVER = require('./eventServer.js') let TASK_MANAGER_SERVER = require('./taskManagerServer.js') @@ -58,31 +58,34 @@ let WEB_SOCKETS_INTERFACE = require('./webSocketsServer.js') let HTTP_INTERFACE = require('./httpInterface.js') try { + console.log('CLIENT SERVERS:') + console.log('') + WEB_SERVER = WEB_SERVER.newWebServer() WEB_SERVER.initialize() WEB_SERVER.run() console.log('Web Server ......................... Started') - DATA_FILE_SERVER = DATA_FILE_SERVER.newDataFileServer() - DATA_FILE_SERVER.initialize() - DATA_FILE_SERVER.run() - console.log('Data File Server ................... Started') + UI_FILE_SERVER = UI_FILE_SERVER.newUIFileServer() + UI_FILE_SERVER.initialize() + UI_FILE_SERVER.run() + console.log('UI File Server ..................... Started') PROJECT_FILE_SERVER = PROJECT_FILE_SERVER.newProjectFileServer() PROJECT_FILE_SERVER.initialize() PROJECT_FILE_SERVER.run() console.log('Project File Server ................ Started') - - WEB_APP_FILE_SERVER = WEB_APP_FILE_SERVER.newWebAppFileServer() - WEB_APP_FILE_SERVER.initialize() - WEB_APP_FILE_SERVER.run() - console.log('Web App File Server ................ Started') - + PLUGIN_SERVER = PLUGIN_SERVER.newPluginServer() PLUGIN_SERVER.initialize() PLUGIN_SERVER.run() console.log('Plugin Server ...................... Started') + DATA_FILE_SERVER = DATA_FILE_SERVER.newDataFileServer() + DATA_FILE_SERVER.initialize() + DATA_FILE_SERVER.run() + console.log('Data File Server ................... Started') + EVENT_SERVER = EVENT_SERVER.newEventServer() EVENT_SERVER.initialize() EVENT_SERVER.run() @@ -103,15 +106,19 @@ try { WEB3_SERVER.run() console.log('WEB3 Server ........................ Started') + console.log('') + console.log('CLIENT INTERFACES:') + console.log('') + WEB_SOCKETS_INTERFACE = WEB_SOCKETS_INTERFACE.newWebSocketsInterface(EVENT_SERVER) WEB_SOCKETS_INTERFACE.initialize() WEB_SOCKETS_INTERFACE.run() - console.log('Web Sockets Interface .............. Started') + console.log('Web Sockets Interface .............. Listening at port ' + process.env.WEB_SOCKETS_INTERFACE_PORT) - HTTP_INTERFACE = HTTP_INTERFACE.newHttpInterface(WEB_SERVER, DATA_FILE_SERVER, PROJECT_FILE_SERVER, WEB_APP_FILE_SERVER, PLUGIN_SERVER, CCXT_SERVER, WEB3_SERVER) + HTTP_INTERFACE = HTTP_INTERFACE.newHttpInterface(WEB_SERVER, DATA_FILE_SERVER, PROJECT_FILE_SERVER, UI_FILE_SERVER, PLUGIN_SERVER, CCXT_SERVER, WEB3_SERVER) HTTP_INTERFACE.initialize() HTTP_INTERFACE.run() - console.log('Http Interface ..................... Started') + console.log('Http Interface ..................... Listening at port ' + process.env.HTTP_INTERFACE_PORT) console.log('') console.log("You are running Superalgos Beta 7") diff --git a/Client/webAppFileServer.js b/Client/uiFileServer.js similarity index 69% rename from Client/webAppFileServer.js rename to Client/uiFileServer.js index 252079813..4b9ae5610 100644 --- a/Client/webAppFileServer.js +++ b/Client/uiFileServer.js @@ -1,6 +1,6 @@ -exports.newWebAppFileServer = function newWebAppFileServer() { +exports.newUIFileServer = function newUIFileServer() { - const MODULE = "Web App File Server" + const MODULE = "UI File Server" let thisObject = { initialize: initialize, diff --git a/Client/webSocketsServer.js b/Client/webSocketsServer.js index cdebc130c..23ef8170a 100644 --- a/Client/webSocketsServer.js +++ b/Client/webSocketsServer.js @@ -12,7 +12,7 @@ require('dotenv').config() const WEB_SOCKET = require('ws') let socketServer - let port = process.env.WEB_SOCKETS_SERVER_PORT + let port = process.env.WEB_SOCKETS_INTERFACE_PORT return thisObject diff --git a/Legacy-Code/Masters/bots/Webhooks-Sensor-Bot/Check-Webhook/User.Bot.js b/Legacy-Code/Masters/bots/Webhooks-Sensor-Bot/Check-Webhook/User.Bot.js index 4037cb4ca..654ae8953 100644 --- a/Legacy-Code/Masters/bots/Webhooks-Sensor-Bot/Check-Webhook/User.Bot.js +++ b/Legacy-Code/Masters/bots/Webhooks-Sensor-Bot/Check-Webhook/User.Bot.js @@ -99,7 +99,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_S let http = require('http'); let url = 'http://' + process.env.WEB_SERVER_URL + - ':' + process.env.WEB_SERVER_PORT + + ':' + process.env.HTTP_INTERFACE_PORT + '/Webhook/Fetch-Messages/' + bot.exchange + "/" + bot.market.baseAsset + "-" + bot.market.quotedAsset diff --git a/TaskServer/EventServerClient.js b/TaskServer/EventServerClient.js index 09bf453cb..2b7f366d0 100644 --- a/TaskServer/EventServerClient.js +++ b/TaskServer/EventServerClient.js @@ -24,7 +24,7 @@ host = 'localhost' } if (port === undefined) { - port = process.env.WEB_SOCKETS_SERVER_PORT + port = process.env.WEB_SOCKETS_INTERFACE_PORT } let messageCounter = 0 diff --git a/run.js b/run.js index 02a2388d1..d6033b73c 100644 --- a/run.js +++ b/run.js @@ -1,14 +1,14 @@ if ( - process.argv.includes("help") || - process.argv.includes("-help") || - process.argv.includes("--help") || + process.argv.includes("help") || + process.argv.includes("-help") || + process.argv.includes("--help") || process.argv.includes("h") || - process.argv.includes("-h") || - process.argv.includes("--h") || - process.argv.includes("/h") || - process.argv.includes("/help") ) { - + process.argv.includes("-h") || + process.argv.includes("--h") || + process.argv.includes("/h") || + process.argv.includes("/help")) { + console.log('Superalgos') console.log('') console.log('VERSION: Beta 7') @@ -28,10 +28,15 @@ if ( console.log(' help: Optional. Use it to see this helping information.') console.log(' noBrowser: Optional. Use it to launch Superalgos Backend only. The UI will not be loaded.') console.log(' minMemo: Optional. Use it when your hardware has less than 8 Gb or memory.') - + return } +console.log('') +console.log('OPTIONS ACCEPTED:') +console.log('') +let optionsAccepted = 0 + let options = { execArgv: ['--max-old-space-size=8192'], stdio: 'inherit' @@ -41,8 +46,20 @@ if (process.argv.includes("minMemo")) { options = { stdio: 'inherit' } - console.log('Running with Minimun Memory Required.') + optionsAccepted++ + console.log('minMemo ............................ Running with Minimun Required Memory.') } +if (process.argv.includes("noBrowser")) { + optionsAccepted++ + console.log('noBrowser .......................... Running without User Interface.') +} + +if (optionsAccepted === 0) { + console.log('none ............................... Running without any command line options.') +} + +console.log('') + const { fork } = require('child_process') fork('./Client/server.js', process.argv, options)