From 3ff1e6f02b6085b96bce9c38d93063b0b3c9b5af Mon Sep 17 00:00:00 2001 From: burturt <31748545+burturt@users.noreply.github.com> Date: Sun, 2 Jun 2024 21:53:54 -0700 Subject: [PATCH] make rejoin tokens local to game instances --- docker-compose.yaml | 10 ++++++++++ player/player.js | 2 +- start.bash | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index ae8af02..801d960 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -3,6 +3,8 @@ services: image: postgres:latest env_file: - .env + environment: + - INSTANCE_NUM=${INSTANCE_NUM:-1} volumes: - dbdata:/var/lib/postgresql/data - ./db/init.sql:/docker-entrypoint-initdb.d/init.sql:ro @@ -12,8 +14,12 @@ services: dockerfile: player/Dockerfile env_file: - .env + environment: + - INSTANCE_NUM=${INSTANCE_NUM:-1} ports: - "${PLAYER_PORT:-2222}:22" + depends_on: + - db server: build: context: . @@ -22,9 +28,13 @@ services: - ADMIN_PASSWORD=${ADMIN_PASSWORD} env_file: - .env + environment: + - INSTANCE_NUM=${INSTANCE_NUM:-1} ports: - "${SERVER_PORT:-2223}:22" - "${SERVER_HTTP_PORT:-8080}:8080" + depends_on: + - db volumes: dbdata: diff --git a/player/player.js b/player/player.js index ef495e3..a22b86e 100644 --- a/player/player.js +++ b/player/player.js @@ -36,7 +36,7 @@ async function waitForOpenSocket(socket) { }); } -const SECRETTOKEN = process.env["JWT_TOKEN"]; +const SECRETTOKEN = process.env["JWT_TOKEN"] + process.env["INSTANCE_NUM"]; const WELCOME = fs.readFileSync("texts/boelter.txt").toString(); const INSTRUCTIONS = fs.readFileSync("texts/instructions.txt").toString(); diff --git a/start.bash b/start.bash index a325dcc..2b56b13 100755 --- a/start.bash +++ b/start.bash @@ -22,6 +22,7 @@ for i in $(seq 1 $n); do export SERVER_PORT=2${suffix}2 export SERVER_HTTP_PORT=2${suffix}1 export PLAYER_PORT=2${suffix}0 + export INSTANCE_NUM=$suffix docker-compose -p ${suffix} up --build -d done