From c633de5eedc03fdf6744f099131a88e12ee3f127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 14 Dec 2020 22:43:05 +0100 Subject: [PATCH] Making HTTP and GRPC ports configurable in API server --- back/server.ts | 6 ++++-- back/src/Enum/EnvironmentVariable.ts | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/back/server.ts b/back/server.ts index 1aa51160..8d761719 100644 --- a/back/server.ts +++ b/back/server.ts @@ -3,11 +3,13 @@ import App from "./src/App"; import grpc from "grpc"; import {roomManager} from "./src/RoomManager"; import {IRoomManagerServer, RoomManagerService} from "./src/Messages/generated/messages_grpc_pb"; +import {HTTP_PORT, GRPC_PORT} from "./src/Enum/EnvironmentVariable"; -App.listen(8080, () => console.log(`WorkAdventure starting on port 8080!`)) +App.listen(HTTP_PORT, () => console.log(`WorkAdventure HTTP API starting on port %d!`, HTTP_PORT)) const server = new grpc.Server(); server.addService(RoomManagerService, roomManager); -server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure()); +server.bind('0.0.0.0:'+GRPC_PORT, grpc.ServerCredentials.createInsecure()); server.start(); +console.log('WorkAdventure HTTP/2 API starting on port %d!', GRPC_PORT); diff --git a/back/src/Enum/EnvironmentVariable.ts b/back/src/Enum/EnvironmentVariable.ts index 3a2ac99e..00750969 100644 --- a/back/src/Enum/EnvironmentVariable.ts +++ b/back/src/Enum/EnvironmentVariable.ts @@ -10,7 +10,9 @@ const CPU_OVERHEAT_THRESHOLD = Number(process.env.CPU_OVERHEAT_THRESHOLD) || 80; const JITSI_URL : string|undefined = (process.env.JITSI_URL === '') ? undefined : process.env.JITSI_URL; const JITSI_ISS = process.env.JITSI_ISS || ''; const SECRET_JITSI_KEY = process.env.SECRET_JITSI_KEY || ''; -export const SOCKET_IDLE_TIMER = parseInt(process.env.SOCKET_IDLE_TIMER as string) || 30; // maximum time (in second) without activity before a socket is closed +const HTTP_PORT = parseInt(process.env.HTTP_PORT || '8080') || 8080; +const GRPC_PORT = parseInt(process.env.GRPC_PORT || '50051') || 50051; +export const SOCKET_IDLE_TIMER = parseInt(process.env.SOCKET_IDLE_TIMER as string) || 30; // maximum time (in second) without activity before a socket is closed export { SECRET_KEY, @@ -18,6 +20,8 @@ export { MINIMUM_DISTANCE, ADMIN_API_URL, ADMIN_API_TOKEN, + HTTP_PORT, + GRPC_PORT, MAX_USERS_PER_ROOM, GROUP_RADIUS, ALLOW_ARTILLERY,