From 11f5689a3e0bc7f8d51b0d4b79e697c81d420445 Mon Sep 17 00:00:00 2001 From: Lorin Hochstein Date: Mon, 23 Jan 2017 22:33:07 -0800 Subject: [PATCH] Wait on postgres --- ch13/ansible/roles/mezzanine/files/entrypoint.sh | 13 +++++++++---- ch13/ansible/roles/mezzanine/tasks/main.yml | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) 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 -- 2.44.0