Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
feat(boot): background the loading of DB data into Kubernetes
Browse files Browse the repository at this point in the history
This uses backgrounding of the management command and uses nohup to manage the running of the task.
Logs (that are not part of the normal Django log loop) will go into /app/data/logs/load_db_state_to_k8s.log

By doing this the Controller can go into a ready state a lot earlier than otherwise when there are a lot of resources (specficially apps)

Readiness and Liveness both have 30 second delay and in that timeframe the initial set of Model save() operations will be able to take place to create the appropriate Namespaces and Services

Generally the slowest part is the Deploy but other Kubernetes resource manipulations can be a tad bit slow.

Closes #746
  • Loading branch information
helgi committed Jul 28, 2016
1 parent 1466e7b commit ba12d09
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion rootfs/bin/boot
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,28 @@ chgrp deis /var/run/docker.sock
groupadd -g "$(stat -c "%g" /var/run/docker.sock)" docker || true
usermod -a -G docker deis || true

echo ""
echo "Django checks:"
python /app/manage.py check --deploy api

echo ""
echo "Health Checks:"
python /app/manage.py healthchecks

echo ""
echo "Database Migrations:"
sudo -E -u deis python /app/manage.py migrate --noinput

# spawn a gunicorn server in the background
echo ""
echo "Starting up Gunicorn"
sudo -E -u deis gunicorn -c /app/deis/gunicorn/config.py api.wsgi &

python /app/manage.py load_db_state_to_k8s
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 &

# smart shutdown on SIGTERM (SIGINT is handled by gunicorn)
function on_exit() {
Expand All @@ -46,6 +55,7 @@ function on_exit() {
}
trap on_exit TERM

echo ""
echo deis-controller running...

wait

0 comments on commit ba12d09

Please sign in to comment.