-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathboot
More file actions
executable file
·51 lines (38 loc) · 1.13 KB
/
boot
File metadata and controls
executable file
·51 lines (38 loc) · 1.13 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
#!/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
[[ $DEBUG ]] && set -x
echo system information:
echo "Django Version: $(./manage.py --version)"
python --version
mkdir -p /app/data/logs
chmod -R 777 /app/data/logs
# allow deis user group permission to Docker socket
if addgroup -g "$(stat -c "%g" /var/run/docker.sock)" docker; then
addgroup deis docker
else
addgroup deis "$(stat -c "%G" /var/run/docker.sock)"
fi
echo "Django checks:"
python /app/manage.py check --deploy api
echo "Health Checks:"
python /app/manage.py healthchecks
echo "Database Migrations:"
sudo -E -u deis python /app/manage.py migrate --noinput
# spawn a gunicorn server in the background
sudo -E -u deis gunicorn -c /app/deis/gconf.py deis.wsgi &
python /app/manage.py load_db_state_to_k8s
# 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 deis-controller running...
wait