Pārlūkot izejas kodu

change port mapping so i dont get rekt

master
peter 5 gadus atpakaļ
vecāks
revīzija
e12bb72632

+ 21
- 15
src/backend/Admin/Admin.ts Parādīt failu

@@ -66,11 +66,18 @@ export class FrontworkAdmin
66 66
     }
67 67
 
68 68
     async start() {
69
+        let port: number = this.config.getConfig().httpPort
70
+
69 71
         await this.makeKnex()
70
-        this.startWebsocket()
72
+        const app = await this.makeExpress()
73
+        const httpServer = new http.Server(app)
74
+        await this.startWebsocket(httpServer)
75
+        httpServer.listen(port)
76
+        await this.attachAngularSSR(app)
77
+        getLogger('Admin#startWebsocket').debug("Webserver up on", port)
78
+
71 79
         await Promise.all(this.frontworkComponents.map(c => c.initialize ? c.initialize() : undefined))
72 80
         getLogger('Admin#start').debug(this.frontworkComponents.length + " components initialized")
73
-        await this.startWebserver()
74 81
     }
75 82
 
76 83
     stop() {
@@ -106,7 +113,7 @@ export class FrontworkAdmin
106 113
             .flatMap(exp => exp.getTableDefinitions())
107 114
     }
108 115
 
109
-    private startWebsocket() {
116
+    private startWebsocket(httpServer: http.Server) {
110 117
         this.rpcServer = new RPCServer([
111 118
             ...this.frontworkComponents,
112 119
             {
@@ -119,24 +126,20 @@ export class FrontworkAdmin
119 126
         ], {
120 127
             errorHandler: (sock, err, rpc, args) => {
121 128
                 console.log(rpc, err);
122
-                
123 129
             }
124
-
125
-        }).listen(20000)
126
-        getLogger('Admin#startWebsocket').debug("Websocket up on", 20000)
130
+        })
131
+        .attach(httpServer)
127 132
     }
128 133
 
129
-    private async startWebserver() {
134
+    private async makeExpress() {
130 135
         if (this.httpServer != null || this.express != null) {
131 136
             getLogger('Admin#startWebserver').warn("Webserver is already running")
132 137
             return
133 138
         }
134 139
 
135
-        let port: number = this.config.getConfig().httpPort
136 140
         this.express = express()
137 141
 
138 142
         const distFolder = "../../../../dist"
139
-        const ngExpressServer = Path.join(__dirname, distFolder, 'server.js')
140 143
 
141 144
         this.express.get('*.*', (req, res) => {
142 145
             //console.log('*.*', req.path);
@@ -153,20 +156,23 @@ export class FrontworkAdmin
153 156
                 res.status(404)
154 157
             }
155 158
         })
159
+        return this.express
160
+    }
161
+
162
+    attachAngularSSR = async (express : express.Application) => {
163
+        const distFolder = "../../../../dist"
164
+        const ngExpressServer = Path.join(__dirname, distFolder, 'server.js')
165
+        let port: number = this.config.getConfig().httpPort
156 166
 
157 167
         try {
158 168
             const req = require(distFolder + "/server.js")
159
-            await req.attachExpress(this.express, './dist', getLogger('angularSSR#'))
169
+            await req.attachExpress(express, './dist', getLogger('angularSSR#'))
160 170
             getLogger('Admin#startWebserver').debug('Frontend from ' + ngExpressServer + " loaded")
161 171
         } catch (e) {
162 172
             getLogger('Admin#startWebserver').error(e)
163 173
             getLogger('Admin#startWebserver').warn("No angular SSR module was provided in " + ngExpressServer)
164 174
             getLogger('Admin#startWebserver').warn("This is not fatal, but your page will not render on *" + port)
165 175
         }
166
-
167
-        this.express.listen(port, () => {
168
-            getLogger('Admin#startWebserver').info('Admin panel listening for HTTP on *' + port)
169
-        })
170 176
     }
171 177
 
172 178
     private stopWebserver() {

+ 2
- 2
src/backend/Components/User/UserManager.ts Parādīt failu

@@ -144,10 +144,10 @@ export class UserManager
144 144
                 }
145 145
             })))
146 146
 
147
-        const rankServer = await this.startRankServer(20001)
147
+        const rankServer = await this.startRankServer(20002)
148 148
         this.rankServer = {
149 149
             server: rankServer,
150
-            port: 20001
150
+            port: 20002
151 151
         }
152 152
         //setInterval(this.checkExpiredSessions, 600_000)
153 153
     }

+ 1
- 1
src/frontend/src/app/frontcraft/services/ApiService/client-login-api.ts Parādīt failu

@@ -132,7 +132,7 @@ export class ClientApiService implements IApiService{
132 132
         }
133 133
 
134 134
         try{
135
-            let conn = new RPCSocket<FrontcraftIfc>(20000, window.location.hostname)
135
+            let conn = new RPCSocket<FrontcraftIfc>(8080, window.location.hostname)
136 136
             conn.on('close', async () => {
137 137
             })                        
138 138
 

+ 1
- 1
src/frontend/src/app/frontcraft/services/ApiService/server-login-api.ts Parādīt failu

@@ -83,7 +83,7 @@ export class ServerApiService implements IApiService {
83 83
         }
84 84
 
85 85
         try {
86
-            let conn = new RPCSocket<FrontcraftIfc>(20000, window.location.hostname)
86
+            let conn = new RPCSocket<FrontcraftIfc>(8080, window.location.hostname)
87 87
             conn.on('close', async () => {
88 88
             })
89 89
 

Notiek ielāde…
Atcelt
Saglabāt