forked from ietf-tools/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcelery-start.sh
More file actions
33 lines (28 loc) · 825 Bytes
/
celery-start.sh
File metadata and controls
33 lines (28 loc) · 825 Bytes
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
#!/bin/bash -e
#
# Run a celery worker
#
echo "Running Datatracker checks..."
./ietf/manage.py check
if ! ietf/manage.py migrate --check ; then
echo "Unapplied migrations found, waiting to start..."
sleep 5
while ! ietf/manage.py migrate --check ; do
echo "... still waiting for migrations..."
sleep 5
done
fi
echo "Starting Celery..."
cleanup () {
# Cleanly terminate the celery app by sending it a TERM, then waiting for it to exit.
if [[ -n "${celery_pid}" ]]; then
echo "Gracefully terminating celery worker. This may take a few minutes if tasks are in progress..."
kill -TERM "${celery_pid}"
wait "${celery_pid}"
fi
}
trap 'trap "" TERM; cleanup' TERM
# start celery in the background so we can trap the TERM signal
celery "$@" &
celery_pid=$!
wait "${celery_pid}"