Skip to content

Commit 7c793e5

Browse files
authored
Better resilience if database doesn't start (#95)
1 parent e799142 commit 7c793e5

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

scripts/infra.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ start_postgres() {
7878
echo "PostgreSQL DB process: $pid"
7979

8080
echo "Waiting for PostgreSQL to be ready..."
81-
timeout 90s bash -c "until ${engine} exec $DB_CONTAINER_NAME pg_isready ; do sleep 5 ; done"
81+
timeout 90s bash -c "until ${engine} exec $DB_CONTAINER_NAME pg_isready ; do sleep 5 ; done" || {
82+
echo "Error: PostgreSQL failed to become ready"
83+
exit 1
84+
}
8285
}
8386

8487
stop_postgres() {

scripts/perf-lab/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ scripts:
177177

178178
start-test-services:
179179
- sh: ${{PROJ_REPO_DIR}}/scripts/infra.sh -c 3 -p '${{config.resources.cpu.db}}' -s
180+
watch:
181+
- regex: "Error: PostgreSQL failed to become ready"
182+
then:
183+
abort: PostgreSQL failed to become ready
180184

181185
stop-test-services:
182186
- sh: ${{PROJ_REPO_DIR}}/scripts/infra.sh -d

0 commit comments

Comments
 (0)