forked from ietf-tools/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatatracker-start.sh
More file actions
60 lines (51 loc) · 1.63 KB
/
datatracker-start.sh
File metadata and controls
60 lines (51 loc) · 1.63 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash -e
echo "Running Datatracker checks..."
./ietf/manage.py check
# Check whether the blobdb database exists - inspectdb will return a false
# status if not.
if ietf/manage.py inspectdb --database blobdb > /dev/null 2>&1; then
HAVE_BLOBDB="yes"
fi
migrations_applied_for () {
local DATABASE=${1:-default}
ietf/manage.py migrate --check --database "$DATABASE"
}
migrations_all_applied () {
if [[ "$HAVE_BLOBDB" == "yes" ]]; then
migrations_applied_for default && migrations_applied_for blobdb
else
migrations_applied_for default
fi
}
if ! migrations_all_applied; then
echo "Unapplied migrations found, waiting to start..."
sleep 5
while ! migrations_all_applied ; do
echo "... still waiting for migrations..."
sleep 5
done
fi
echo "Starting Datatracker..."
# trap TERM and shut down gunicorn
cleanup () {
if [[ -n "${gunicorn_pid}" ]]; then
echo "Terminating gunicorn..."
kill -TERM "${gunicorn_pid}"
wait "${gunicorn_pid}"
fi
}
trap 'trap "" TERM; cleanup' TERM
# start gunicorn in the background so we can trap the TERM signal
gunicorn \
-c /workspace/gunicorn.conf.py \
--workers "${DATATRACKER_GUNICORN_WORKERS:-9}" \
--max-requests "${DATATRACKER_GUNICORN_MAX_REQUESTS:-32768}" \
--timeout "${DATATRACKER_GUNICORN_TIMEOUT:-180}" \
--bind :8000 \
--log-level "${DATATRACKER_GUNICORN_LOG_LEVEL:-info}" \
--capture-output \
--access-logfile -\
${DATATRACKER_GUNICORN_EXTRA_ARGS} \
ietf.wsgi:application &
gunicorn_pid=$!
wait "${gunicorn_pid}"