From 743885aff59e02dcc170e553e8a468ad0e270200 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 31 Aug 2021 13:26:55 +0200 Subject: [PATCH] runNetworkScript Debugged --- EnvironmentForDebug.js | 23 ++++--- Network/NetwokNode.js | 69 +++++-------------- .../Network/NT/Modules/WebSocketsInterface.js | 2 +- .../package-lock.json => package-lock.json | 0 Network/package.json => package.json | 0 runNetwork.js | 52 ++++++++++++++ 6 files changed, 82 insertions(+), 64 deletions(-) rename Network/package-lock.json => package-lock.json (100%) rename Network/package.json => package.json (100%) create mode 100644 runNetwork.js diff --git a/EnvironmentForDebug.js b/EnvironmentForDebug.js index cbb68d289..5e88fb9da 100644 --- a/EnvironmentForDebug.js +++ b/EnvironmentForDebug.js @@ -3,19 +3,20 @@ exports.newEnvironment = function () { let thisObject = { WEB_SERVER_URL: 'localhost', CLIENT_WEB_SOCKETS_INTERFACE_PORT: 18041, + NETWORK_WEB_SOCKETS_INTERFACE_PORT: 18042, HTTP_INTERFACE_PORT: 34248, - PATH_TO_TASK_SERVER: '../TaskServer', - PATH_TO_DATA_STORAGE: '../Data-Storage', - PATH_TO_PROJECTS: '../Projects', - PATH_TO_LOG_FILES: '../Log-Files', + PATH_TO_TASK_SERVER: './TaskServer', + PATH_TO_DATA_STORAGE: './Data-Storage', + PATH_TO_PROJECTS: './Projects', + PATH_TO_LOG_FILES: './Log-Files', PATH_TO_PROJECTS_REQUIRED: './Projects', - PATH_TO_PROJECT_SCHEMA: '../Projects/ProjectsSchema.json', - PATH_TO_UI: '../UI', - PATH_TO_DATA_FILES: '../UI/Data-Files/src', - PATH_TO_CLIENT: '../Client/', - PATH_TO_DEFAULT_WORKSPACE: '../Projects/Foundations/Plugins/Workspaces', - PATH_TO_MY_WORKSPACES: '../My-Workspaces', - PATH_TO_FONTS: '../Client/WebServer/Fonts' + PATH_TO_PROJECT_SCHEMA: './Projects/ProjectsSchema.json', + PATH_TO_UI: './UI', + PATH_TO_DATA_FILES: './UI/Data-Files/src', + PATH_TO_CLIENT: './Client/', + PATH_TO_DEFAULT_WORKSPACE: './Projects/Foundations/Plugins/Workspaces', + PATH_TO_MY_WORKSPACES: './My-Workspaces', + PATH_TO_FONTS: './Client/WebServer/Fonts' } return thisObject diff --git a/Network/NetwokNode.js b/Network/NetwokNode.js index b3eb4577f..8406c76df 100644 --- a/Network/NetwokNode.js +++ b/Network/NetwokNode.js @@ -1,59 +1,24 @@ -/* -The Superalgos Network offers 3 types of services: +exports.newNetworkNode = function newNetworkNode() { - * Social Graph Service - * Search Index Service - * Private Message Service - -Users can decide which services to run at their node. + let thisObject = { + run: run + } -This module is the starting point of the Network Node. + return thisObject -*/ + function run() { + /* + Let's start the Network Interfaces + */ + NT.webSocketsInterface = NT.projects.network.modules.webSocketsInterface.newNetworkModulesWebSocketsInterface() + NT.webSocketsInterface.initialize() -/* -The NT object is accesible everywhere at the Superalgos Network. -It provides access to all modules built for this Network. -*/ -global.NT = {} -/* -The SA object is accesible everywhere at the Superalgos Network. -It provides access to all modules built for Superalgos in general. -*/ -global.SA = {} -/* Load Environment Variables */ -let ENVIRONMENT = require('../EnvironmentForDebug.js'); -let ENVIRONMENT_MODULE = ENVIRONMENT.newEnvironment() -global.env = ENVIRONMENT_MODULE -/* -First thing is to load the project schema file. -*/ -global.PROJECTS_SCHEMA = require(global.env.PATH_TO_PROJECT_SCHEMA) -/* -Setting up the modules that will be available for the Servers Running inside this Client -*/ -let MULTI_PROJECT = require('../MultiProject.js'); -let MULTI_PROJECT_MODULE = MULTI_PROJECT.newMultiProject() -MULTI_PROJECT_MODULE.initialize(NT, 'NT') -MULTI_PROJECT_MODULE.initialize(SA, 'SA') -/* -Setting up external dependencies. -*/ -SA.nodeModules = { - fs: require('fs'), - nodeFetch: require('node-fetch'), - web3: require('web3'), - ws: require('ws') -} -/* -Let's start the Network Interfaces -*/ -NT.webSocketsInterface = NT.projects.network.modules.webSocketsInterface.newNetworkModulesWebSocketsInterface() -NT.webSocketsInterface.initialize() + start() -start() + async function start() { + let socialGraphService = NT.projects.network.modules.socialGraph.newSocialGraph() + await socialGraphService.initialize() + } -async function start() { - let socialGraphService = NT.projects.network.modules.socialGraph.newSocialGraph() - await socialGraphService.initialize() + } } diff --git a/Projects/Network/NT/Modules/WebSocketsInterface.js b/Projects/Network/NT/Modules/WebSocketsInterface.js index 740e6d244..912a66740 100644 --- a/Projects/Network/NT/Modules/WebSocketsInterface.js +++ b/Projects/Network/NT/Modules/WebSocketsInterface.js @@ -18,7 +18,7 @@ exports.newNetworkModulesWebSocketsInterface = function newNetworkModulesWebSock } function initialize() { - socketServer = new SA.nodeModule.ws.Server({ port: global.env.Network_WEB_SOCKETS_INTERFACE_PORT }) + socketServer = new SA.nodeModules.ws.Server({ port: global.env.NETWORK_WEB_SOCKETS_INTERFACE_PORT }) clientInterface = NT.projects.network.modules.clientInterface.newNetworkModulesClientInterface() peerInterface = NT.projects.network.modules.peerInterface.newNetworkModulesPeerInterface() diff --git a/Network/package-lock.json b/package-lock.json similarity index 100% rename from Network/package-lock.json rename to package-lock.json diff --git a/Network/package.json b/package.json similarity index 100% rename from Network/package.json rename to package.json diff --git a/runNetwork.js b/runNetwork.js new file mode 100644 index 000000000..9aae83d5e --- /dev/null +++ b/runNetwork.js @@ -0,0 +1,52 @@ +/* +The Superalgos Network offers 3 types of services: + + * Social Graph Service + * Search Index Service + * Private Message Service + +Users can decide which services to run at their node.(TODO) + +This module is the starting point of the Network Node. + +*/ + +/* +The NT object is accesible everywhere at the Superalgos Network. +It provides access to all modules built for this Network. +*/ +global.NT = {} +/* +The SA object is accesible everywhere at the Superalgos Network. +It provides access to all modules built for Superalgos in general. +*/ +global.SA = {} +/* Load Environment Variables */ +let ENVIRONMENT = require('./EnvironmentForDebug.js'); +let ENVIRONMENT_MODULE = ENVIRONMENT.newEnvironment() +global.env = ENVIRONMENT_MODULE +/* +First thing is to load the project schema file. +*/ +global.PROJECTS_SCHEMA = require(global.env.PATH_TO_PROJECT_SCHEMA) +/* +Setting up the modules that will be available, defined at the Project Schema file. +*/ +let MULTI_PROJECT = require('./MultiProject.js'); +let MULTI_PROJECT_MODULE = MULTI_PROJECT.newMultiProject() +MULTI_PROJECT_MODULE.initialize(NT, 'NT') +MULTI_PROJECT_MODULE.initialize(SA, 'SA') +/* +Setting up external dependencies. +*/ +SA.nodeModules = { + fs: require('fs'), + nodeFetch: require('node-fetch'), + web3: require('web3'), + ws: require('ws') +} + +NT.app = require('./Network/NetwokNode.js').newNetworkNode() +NT.app.run() + +console.log('Superalgos Network is Running.') \ No newline at end of file