Skip to content

Commit 9e2a164

Browse files
MoralCodeguptapratykshhSukuna0007Abhi
committed
add health checks to rabbit and postgres to ensure they are healthy before CollectOSS starts.
This avoids some race conditions with the startup process that could create issues, especially on first initialization and especially in CI where we are still replaying migrations Co-Authored-By: guptapratykshh <pratykshgupta9999@gmail.com> Co-Authored-By: Sukuna0007Abhi <appsonly310@gmail.com> Signed-off-by: Adrian Edwards <adredwar@redhat.com>
1 parent 51d1f32 commit 9e2a164

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

docker-compose.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ services:
1414
- "${COLLECTOSS_DB_PORT:-5432}:5432"
1515
volumes:
1616
- augurpostgres:/var/lib/postgresql/data
17+
healthcheck:
18+
test:
19+
[
20+
"CMD-SHELL",
21+
"pg_isready -U ${COLLECTOSS_DB_USER:-augur} -d ${COLLECTOSS_DB_NAME:-augur}",
22+
]
23+
interval: 10s
24+
timeout: 5s
25+
retries: 5
1726

1827
redis:
1928
image: "redis:alpine"
@@ -39,6 +48,12 @@ services:
3948
- RABBIT_MQ_DEFAULT_USER=${COLLECTOSS_RABBITMQ_USERNAME:-augur}
4049
- RABBIT_MQ_DEFAULT_PASSWORD=${COLLECTOSS_RABBITMQ_PASSWORD:-password123}
4150
- RABBIT_MQ_DEFAULT_VHOST=${COLLECTOSS_RABBITMQ_VHOST:-collectoss_vhost}
51+
healthcheck:
52+
test: ["CMD", "rabbitmq-diagnostics", "ping"]
53+
interval: 10s
54+
timeout: 5s
55+
retries: 10
56+
start_period: 10s
4257

4358
core:
4459
image: collectoss:latest
@@ -74,10 +89,14 @@ services:
7489
- CACHE_LOCKDIR=/cache
7590
- CELERYBEAT_SCHEDULE_DB=/tmp/celerybeat-schedule.db
7691
depends_on:
77-
- database
78-
- redis
79-
- keyman
80-
- rabbitmq
92+
database:
93+
condition: service_healthy
94+
redis:
95+
condition: service_started
96+
keyman:
97+
condition: service_started
98+
rabbitmq:
99+
condition: service_healthy
81100
user: 2345:2345 # Run as an arbitrary non-root user
82101
post_start:
83102
# Make sure the user has access to the volumes

0 commit comments

Comments
 (0)