forked from TandoorRecipes/recipes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot.sh
35 lines (27 loc) · 1005 Bytes
/
boot.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
#!/bin/sh
source venv/bin/activate
echo "Migrating database"
attempt=0
max_attempts=20
while python manage.py migrate; \
status=$?; \
attempt=$((attempt+1)); \
[ $status -eq 1 ] \
&& [ $attempt -le $max_attempts ]; do
echo -e "\n!!! Migration failed (error ${status}, attempt ${attempt}/${max_attempts})."
echo "!!! Database may not be ready yet or system is misconfigured."
echo -e "!!! Retrying in 5 seconds...\n"
sleep 5
done
if [ $attempt -gt $max_attempts ]; then
echo -e "\n!!! Migration failed. Maximum attempts exceeded."
echo "!!! Please check logs above - misconfiguration is very likely."
echo "!!! Shutting down container."
exit 1 # exit with error to make the container stop
fi
echo "Generating static files"
python manage.py collectstatic_js_reverse
python manage.py collectstatic --noinput
echo "Done"
chmod -R 755 /opt/recipes/mediafiles
exec gunicorn -b :8080 --access-logfile - --error-logfile - --log-level INFO recipes.wsgi