-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathboot
More file actions
executable file
·56 lines (45 loc) · 1.61 KB
/
boot
File metadata and controls
executable file
·56 lines (45 loc) · 1.61 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
#!/usr/bin/env bash
#
# This script is designed to be run inside the container
#
# fail hard and fast even on pipelines
set -eo pipefail
# set debug based on envvar
[[ $DRYCC_DEBUG == "true" ]] && set -x
echo system information:
echo "Django Version: $(./manage.py --version)"
python --version
mkdir -p /app/data/logs
chmod -R 777 /app/data/logs
echo "Django checks:"
python /app/manage.py check --deploy api
echo ""
echo "Health Checks:"
python /app/manage.py healthchecks
echo ""
echo "Database Migrations:"
python /app/manage.py migrate --noinput
# spawn a gunicorn server in the background
echo ""
echo "Starting up Gunicorn"
gunicorn -c /app/drycc/gunicorn/config.py api.wsgi &
echo ""
echo "Loading database information to Kubernetes in the background"
echo "Log of the run can be found in /app/data/logs/load_db_state_to_k8s.log"
# python -u avoids output buffering
nohup python -u /app/manage.py load_db_state_to_k8s > /app/data/logs/load_db_state_to_k8s.log &
# celery
nohup su-exec nobody celery -A api worker -Q priority.low --autoscale=8,1 --loglevel=WARNING > /app/data/logs/celery.log 2>&1 &
nohup su-exec nobody celery -A api worker -Q priority.middle --autoscale=16,1 --loglevel=WARNING > /app/data/logs/celery.log 2>&1 &
nohup su-exec nobody celery -A api worker -Q priority.high --autoscale=32,1 --loglevel=WARNING > /app/data/logs/celery.log 2>&1 &
# smart shutdown on SIGTERM (SIGINT is handled by gunicorn)
function on_exit() {
GUNICORN_PID=$(cat /tmp/gunicorn.pid)
kill -TERM "$GUNICORN_PID" 2>/dev/null
wait "$GUNICORN_PID" 2>/dev/null
exit 0
}
trap on_exit TERM
echo ""
echo drycc-controller running...
wait