-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_web.sh
executable file
·48 lines (44 loc) · 1.24 KB
/
run_web.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
46
47
48
#!/bin/bash
##
# Version: 1.2
# Author: [email protected]
# Date: 3/21/2015
##
# Simple retry function
function retry {
local n=1
local max=5
local delay=10
while true; do
"$@" && break || {
if [[ ${n} -lt ${max} ]]; then
((n++))
echo "Migration failed. Attempt $n/$max:"
sleep ${delay};
else
echo "The command has failed after $n attempts."
exit 1
fi
}
done
}
## Validate the django project is going to load properly (does not mean it will run)
python manage.py validate
###
# migrate db, so we have the latest db schema
#
# Need to retry so if postgres is starting for the first time.
# Also allows time to see any errors before it attempts to start the server.
##
retry python manage.py migrate --noinput
## Collect all the static files.
python manage.py collectstatic --noinput
##
# start server on the docker ip interface, port 8001
# Also handles if we are going to start the production gunicorn server or the develop server
##
if [ -z ${DJANGO_DEBUG_MODE} ]; then
su -m djuser -c "gunicorn boil_project.wsgi -w 1 -b 0.0.0.0:8001 --chdir=/code --enable-stdio-inheritance --error-logfile -"
else
su -m djuser -c "python manage.py runserver 0.0.0.0:8001"
fi