From: Lorin Hochstein Date: Tue, 24 Jan 2017 06:33:07 +0000 (-0800) Subject: Wait on postgres X-Git-Url: https://git.halfball.org/?a=commitdiff_plain;h=11f5689a3e0bc7f8d51b0d4b79e697c81d420445;p=ansiblebook.git Wait on postgres --- diff --git a/ch13/ansible/roles/mezzanine/files/entrypoint.sh b/ch13/ansible/roles/mezzanine/files/entrypoint.sh index 57ba6ea..265e0c6 100644 --- a/ch13/ansible/roles/mezzanine/files/entrypoint.sh +++ b/ch13/ansible/roles/mezzanine/files/entrypoint.sh @@ -1,15 +1,20 @@ #!/bin/bash # Adapted from https://github.com/ansible/django-gulp-nginx +# https://github.com/ansible/django-gulp-nginx/blob/master/ansible/roles/django-gunicorn/files/entrypoint.sh MANAGE=/srv/project/manage.py +BINDIR=/srv/bin set -x if [[ $@ == *"gunicorn"* || $@ == *"runserver"* ]]; then if [[ -f $MANAGE ]]; then - $MANAGE migrate --noinput - $MANAGE collectstatic --noinput - /srv/bin/setsite.py - /srv/bin/setadmin.py + $BINDIR/wait_on_postgres.py + if [[ $? == 0 ]]; then + $MANAGE migrate --noinput + $MANAGE collectstatic --noinput + $BINDIR/setsite.py + $BINDIR/setadmin.py + fi fi fi diff --git a/ch13/ansible/roles/mezzanine/tasks/main.yml b/ch13/ansible/roles/mezzanine/tasks/main.yml index 2648fb4..cae7a7f 100644 --- a/ch13/ansible/roles/mezzanine/tasks/main.yml +++ b/ch13/ansible/roles/mezzanine/tasks/main.yml @@ -29,3 +29,4 @@ - entrypoint.sh - setsite.py - setadmin.py + - wait_on_postgres.py