Wait on postgres
authorLorin Hochstein <lhochstein@netflix.com>
Tue, 24 Jan 2017 06:33:07 +0000 (22:33 -0800)
committerLorin Hochstein <lhochstein@netflix.com>
Tue, 24 Jan 2017 06:33:07 +0000 (22:33 -0800)
ch13/ansible/roles/mezzanine/files/entrypoint.sh
ch13/ansible/roles/mezzanine/tasks/main.yml

index 57ba6ea..265e0c6 100644 (file)
@@ -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
 
index 2648fb4..cae7a7f 100644 (file)
@@ -29,3 +29,4 @@
     - entrypoint.sh
     - setsite.py
     - setadmin.py
+    - wait_on_postgres.py