Skip to content

Commit 95973cd

Browse files
committed
🔨 [#458] Add timeout to check if migrations are done
1 parent 5b529dd commit 95973cd

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

backend/bin/setup_configuration.sh

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
#!/bin/sh
22

3+
# Waiting for database to be up
34
until pg_isready; do
45
>&2 echo "Waiting for database connection..."
56
sleep 1
67
done
78

8-
until python src/manage.py migrate --check; do
9-
>&2 echo "Waiting for migrations to be done..."
10-
sleep 1
9+
# Waiting for migrations to be done
10+
attempt_counter=0
11+
max_attempts=${CHECK_MIGRATIONS_MAX_ATTEMPT:-10}
12+
13+
while ! python src/manage.py migrate --check; do
14+
attempt_counter=$((attempt_counter + 1))
15+
16+
if [ $attempt_counter -ge $max_attempts ]; then
17+
>&2 echo "Timed out while waiting for django migrations."
18+
exit 1
19+
fi
20+
21+
>&2 echo "Attempt $attempt_counter/$max_attempts: Waiting for migrations to be done..."
22+
sleep 10
1123
done
1224

1325
# Run setup configuration

0 commit comments

Comments
 (0)