Skip to content

Commit

Permalink
make rejoin tokens local to game instances
Browse files Browse the repository at this point in the history
  • Loading branch information
burturt committed Jun 3, 2024
1 parent 8bdcd20 commit 3ff1e6f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: .
Expand All @@ -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:
2 changes: 1 addition & 1 deletion player/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions start.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3ff1e6f

Please sign in to comment.