change port mapping so i dont get rekt
This commit is contained in:
+22
-16
@@ -66,11 +66,18 @@ export class FrontworkAdmin
|
||||
}
|
||||
|
||||
async start() {
|
||||
let port: number = this.config.getConfig().httpPort
|
||||
|
||||
await this.makeKnex()
|
||||
this.startWebsocket()
|
||||
const app = await this.makeExpress()
|
||||
const httpServer = new http.Server(app)
|
||||
await this.startWebsocket(httpServer)
|
||||
httpServer.listen(port)
|
||||
await this.attachAngularSSR(app)
|
||||
getLogger('Admin#startWebsocket').debug("Webserver up on", port)
|
||||
|
||||
await Promise.all(this.frontworkComponents.map(c => c.initialize ? c.initialize() : undefined))
|
||||
getLogger('Admin#start').debug(this.frontworkComponents.length + " components initialized")
|
||||
await this.startWebserver()
|
||||
}
|
||||
|
||||
stop() {
|
||||
@@ -106,7 +113,7 @@ export class FrontworkAdmin
|
||||
.flatMap(exp => exp.getTableDefinitions())
|
||||
}
|
||||
|
||||
private startWebsocket() {
|
||||
private startWebsocket(httpServer: http.Server) {
|
||||
this.rpcServer = new RPCServer([
|
||||
...this.frontworkComponents,
|
||||
{
|
||||
@@ -119,24 +126,20 @@ export class FrontworkAdmin
|
||||
], {
|
||||
errorHandler: (sock, err, rpc, args) => {
|
||||
console.log(rpc, err);
|
||||
|
||||
}
|
||||
})
|
||||
.attach(httpServer)
|
||||
}
|
||||
|
||||
}).listen(20000)
|
||||
getLogger('Admin#startWebsocket').debug("Websocket up on", 20000)
|
||||
}
|
||||
|
||||
private async startWebserver() {
|
||||
private async makeExpress() {
|
||||
if (this.httpServer != null || this.express != null) {
|
||||
getLogger('Admin#startWebserver').warn("Webserver is already running")
|
||||
return
|
||||
}
|
||||
|
||||
let port: number = this.config.getConfig().httpPort
|
||||
this.express = express()
|
||||
|
||||
const distFolder = "../../../../dist"
|
||||
const ngExpressServer = Path.join(__dirname, distFolder, 'server.js')
|
||||
|
||||
this.express.get('*.*', (req, res) => {
|
||||
//console.log('*.*', req.path);
|
||||
@@ -153,20 +156,23 @@ export class FrontworkAdmin
|
||||
res.status(404)
|
||||
}
|
||||
})
|
||||
return this.express
|
||||
}
|
||||
|
||||
attachAngularSSR = async (express : express.Application) => {
|
||||
const distFolder = "../../../../dist"
|
||||
const ngExpressServer = Path.join(__dirname, distFolder, 'server.js')
|
||||
let port: number = this.config.getConfig().httpPort
|
||||
|
||||
try {
|
||||
const req = require(distFolder + "/server.js")
|
||||
await req.attachExpress(this.express, './dist', getLogger('angularSSR#'))
|
||||
await req.attachExpress(express, './dist', getLogger('angularSSR#'))
|
||||
getLogger('Admin#startWebserver').debug('Frontend from ' + ngExpressServer + " loaded")
|
||||
} catch (e) {
|
||||
getLogger('Admin#startWebserver').error(e)
|
||||
getLogger('Admin#startWebserver').warn("No angular SSR module was provided in " + ngExpressServer)
|
||||
getLogger('Admin#startWebserver').warn("This is not fatal, but your page will not render on *" + port)
|
||||
}
|
||||
|
||||
this.express.listen(port, () => {
|
||||
getLogger('Admin#startWebserver').info('Admin panel listening for HTTP on *' + port)
|
||||
})
|
||||
}
|
||||
|
||||
private stopWebserver() {
|
||||
|
||||
@@ -144,10 +144,10 @@ export class UserManager
|
||||
}
|
||||
})))
|
||||
|
||||
const rankServer = await this.startRankServer(20001)
|
||||
const rankServer = await this.startRankServer(20002)
|
||||
this.rankServer = {
|
||||
server: rankServer,
|
||||
port: 20001
|
||||
port: 20002
|
||||
}
|
||||
//setInterval(this.checkExpiredSessions, 600_000)
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ export class ClientApiService implements IApiService{
|
||||
}
|
||||
|
||||
try{
|
||||
let conn = new RPCSocket<FrontcraftIfc>(20000, window.location.hostname)
|
||||
let conn = new RPCSocket<FrontcraftIfc>(8080, window.location.hostname)
|
||||
conn.on('close', async () => {
|
||||
})
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ export class ServerApiService implements IApiService {
|
||||
}
|
||||
|
||||
try {
|
||||
let conn = new RPCSocket<FrontcraftIfc>(20000, window.location.hostname)
|
||||
let conn = new RPCSocket<FrontcraftIfc>(8080, window.location.hostname)
|
||||
conn.on('close', async () => {
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user