-
Notifications
You must be signed in to change notification settings - Fork 592
/
docker-entrypoint.sh
executable file
·45 lines (37 loc) · 1.04 KB
/
docker-entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
set -e
function wait_for_broker {
set +e
for try in {1..60} ; do
python -c "from kombu import Connection; x=Connection('$CELERY_BROKER_URL', timeout=1); x.connect()" && break
echo "Waiting for celery broker to respond..."
sleep 1
done
}
function wait_for_database {
set +e
for try in {1..60} ; do
python -c "from django.db import connection; connection.connect()" && break
echo "Waiting for database to respond..."
sleep 1
done
}
function wait_for_migrations {
set +e
for try in {1..60} ; do
# Kind of ugly but not sure if there's another way to determine if migrations haven't run.
# showmigrations -p returns a checkbox list of migrations, empty checkboxes mean they haven't been run
python manage.py showmigrations -p | grep "\[ \]" &> /dev/null || break
echo "Waiting for database migrations to be run..."
sleep 1
done
}
wait_for_broker
wait_for_database
if [ -z "$SKIP_INIT" ]; then
/code/bin/build-app
fi
if [ -n "$WAIT_FOR_MIGRATIONS" ]; then
wait_for_migrations
fi
exec "$@"