Skip to content

Commit

Permalink
Start platform with dashboard feature!
Browse files Browse the repository at this point in the history
"node platform dashboards"
  • Loading branch information
zahirsolak committed Oct 19, 2022
1 parent 1ff65a0 commit 590876f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Dashboards/Client/websocketServer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const {newEnvironment} = require("../../Environment")

exports.newWebSocketsServer = function newWebSocketsServer() {

let thisObject = {
Expand All @@ -6,7 +8,7 @@ exports.newWebSocketsServer = function newWebSocketsServer() {
}

const WEB_SOCKET = SA.nodeModules.ws
const port = '18043' //global.env.DASHBOARDS_WEB_SOCKETS_INTERFACE_PORT
const port = newEnvironment().DASHBOARDS_WEB_SOCKETS_INTERFACE_PORT // '18043'
let socketServer
let UISocket

Expand Down
33 changes: 32 additions & 1 deletion Launch-Scripts/runDashboards.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const os = require('os')
const child_process = require('child_process')
const {newEnvironment} = require("../Environment")

const fatalErrorHelp = () => {
console.log('')
Expand Down Expand Up @@ -114,7 +115,37 @@ const runDashboards = () => {

}

function getDashboardPort(){
const envParamters = newEnvironment();
return envParamters.DASHBOARDS_WEB_SOCKETS_INTERFACE_PORT;
}

function checkDashboardStatus() {
return new Promise(resolve=>{
let net = require('net')
net.connect(getDashboardPort(),()=>{
resolve(true)
})
.addListener("error",err=>{
resolve(false)
})
})
}
function runFirstDashboards(testAction){
checkDashboardStatus().then(dashboardIsActive=>{
if(dashboardIsActive)
setTimeout(()=>testAction(),1000)
else{
runDashboards()
setTimeout(()=>runFirstDashboards(testAction),1000)
}
})
}

module.exports = {
runDashboards,
fatalErrorHelp
fatalErrorHelp,
checkDashboardStatus,
getDashboardPort,
runFirstDashboards
}
9 changes: 8 additions & 1 deletion platform.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
const { runPlatform } = require('./Launch-Scripts/runPlatform')
const { runFirstDashboards } = require('./Launch-Scripts/runDashboards')

runPlatform()

if(process.argv.includes("dashboards")){
runFirstDashboards(()=>runPlatform())
}
else{
runPlatform()
}

0 comments on commit 590876f

Please sign in to comment.