Skip to content

Commit ba12d09

Browse files
committed
feat(boot): background the loading of DB data into Kubernetes
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
1 parent 1466e7b commit ba12d09

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

rootfs/bin/boot

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,28 @@ chgrp deis /var/run/docker.sock
2323
groupadd -g "$(stat -c "%g" /var/run/docker.sock)" docker || true
2424
usermod -a -G docker deis || true
2525

26+
echo ""
2627
echo "Django checks:"
2728
python /app/manage.py check --deploy api
2829

30+
echo ""
2931
echo "Health Checks:"
3032
python /app/manage.py healthchecks
3133

34+
echo ""
3235
echo "Database Migrations:"
3336
sudo -E -u deis python /app/manage.py migrate --noinput
3437

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

38-
python /app/manage.py load_db_state_to_k8s
43+
echo ""
44+
echo "Loading database information to Kubernetes in the background"
45+
echo "Log of the run can be found in /app/data/logs/load_db_state_to_k8s.log"
46+
# python -u avoids output buffering
47+
nohup python -u /app/manage.py load_db_state_to_k8s > /app/data/logs/load_db_state_to_k8s.log &
3948

4049
# smart shutdown on SIGTERM (SIGINT is handled by gunicorn)
4150
function on_exit() {
@@ -46,6 +55,7 @@ function on_exit() {
4655
}
4756
trap on_exit TERM
4857

58+
echo ""
4959
echo deis-controller running...
5060

5161
wait

0 commit comments

Comments
 (0)