Skip to content

Commit 771a297

Browse files
committed
PEER-255 Add health checks to prevent service race conditions
Signed-off-by: SeeuSim <[email protected]>
1 parent 684ba23 commit 771a297

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

backend/collaboration/.env.local

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
EXPRESS_ENV="local"
22
EXPRESS_DB_HOST="localhost"
33
EXPRESS_DB_PORT=5434
4-
POSTGRES_DB="collaboration"
4+
POSTGRES_DB="collab"
55
POSTGRES_USER="peerprep-collab-express"
66
POSTGRES_PASSWORD="/86awM+Izo6949YgEQIls8HU+j5RlFYEInRy8auiNa8="
77
PGDATA="/data/collab-db"

docker-compose.yaml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ services:
1616
restart: unless-stopped
1717
networks:
1818
- user-db-network
19+
healthcheck:
20+
test: ["CMD-SHELL", "pg_isready -U peerprep-user-express -d user"]
21+
interval: 10s
22+
retries: 5
23+
start_period: 30s
24+
timeout: 10s
1925

2026
collab-db:
2127
hostname: "collab-db"
@@ -30,6 +36,12 @@ services:
3036
restart: unless-stopped
3137
networks:
3238
- collab-db-network
39+
healthcheck:
40+
test: ["CMD-SHELL", "pg_isready -U peerprep-collab-express -d collab"]
41+
interval: 10s
42+
retries: 5
43+
start_period: 30s
44+
timeout: 10s
3345

3446
question-db:
3547
hostname: "question-db"
@@ -44,6 +56,12 @@ services:
4456
restart: unless-stopped
4557
networks:
4658
- question-db-network
59+
healthcheck:
60+
test: ["CMD-SHELL", "pg_isready -U peerprep-qn-express -d question"]
61+
interval: 10s
62+
retries: 5
63+
start_period: 30s
64+
timeout: 10s
4765

4866
# Services
4967

@@ -63,13 +81,15 @@ services:
6381
env_file:
6482
- ./backend/user/.env.compose
6583
environment:
66-
# Docker Compose Specific
84+
# Docker Compose Specific for Service Discovery
6785
- EXPRESS_DB_HOST=user-db
6886
- EXPRESS_DB_PORT=5432
6987
volumes:
7088
- user-service:/data/user-express
7189
depends_on:
72-
- user-db
90+
user-db:
91+
condition: service_healthy
92+
restart: true
7393
networks:
7494
- user-db-network
7595
- user-api-network

0 commit comments

Comments
 (0)