Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

Commit 6e1b974

Browse files
merge: #3442
3442: fix: add healthcheck to postgres + only report healthy when database are available r=johnrwatson a=johnrwatson This prevents downstream services to postgres starting before the databases in postgres are available Validated locally. Needs the clients to pull the newest image for postgres to consume the change. Co-authored-by: John Watson <john@familywatson.co.uk>
2 parents d916049 + 7765285 commit 6e1b974

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

component/postgres/multiple-database-support.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ create_db() {
3636
EOF
3737
}
3838

39+
# This adds a "ready-file" so that the postgres container only reports ready
40+
# after all the databases have been created. This prevents SDF or any other
41+
# consuming service starting before postgres is ready
42+
echo "ready" >/tmp/ready
43+
3944
die() {
4045
printf -- "\nxxx %s\n\n" "$1" >&2
4146
exit 1

dev/docker-compose.platform.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ services:
1212
- "POSTGRES_MULTIPLE_DBS=si_content_store,si_layer_db,si_auth,si_module_index,si_key_value_pairs"
1313
ports:
1414
- "5432:5432"
15+
healthcheck:
16+
test: ["CMD-SHELL", "[ -f /tmp/ready ]"]
17+
interval: 5s
18+
timeout: 10s
19+
retries: 5
1520

1621
postgres-test:
1722
image: systeminit/postgres:stable
@@ -28,6 +33,11 @@ services:
2833
- "full_page_writes=off"
2934
ports:
3035
- "6432:5432"
36+
healthcheck:
37+
test: ["CMD-SHELL", "[ -f /tmp/ready ]"]
38+
interval: 5s
39+
timeout: 10s
40+
retries: 5
3141

3242
nats:
3343
image: systeminit/nats:stable
@@ -37,6 +47,11 @@ services:
3747
ports:
3848
- "4222:4222"
3949
- "8222:8222"
50+
# We can't have the docker-compose finish before postgres is ready, this is
51+
# a workaround to allow the rest of the tilt file continue to create sdf etc
52+
# so that the start doesn't fail as the databases don't exist
53+
depends_on:
54+
- postgres
4055

4156
jaeger:
4257
image: systeminit/jaeger:stable

0 commit comments

Comments
 (0)