From: Guillaume Pellerin Date: Mon, 25 Jan 2016 20:24:24 +0000 (+0100) Subject: add wait.py for available database X-Git-Tag: 1.6b~6^2~3 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=887bbe264e53ece98bb3475b9fa717ba80d5dd2b;p=telemeta.git add wait.py for available database --- diff --git a/app/deploy/start_app.sh b/app/deploy/start_app.sh index 2cfb60c1..4b626e0a 100644 --- a/app/deploy/start_app.sh +++ b/app/deploy/start_app.sh @@ -21,6 +21,9 @@ pip install django-environ redis # waiting for other services sh $app/deploy/wait.sh +# waiting for available database +python $app/wait.py + # django init python $manage syncdb --noinput python $manage migrate --noinput diff --git a/app/wait.py b/app/wait.py new file mode 100644 index 00000000..eead53c7 --- /dev/null +++ b/app/wait.py @@ -0,0 +1,14 @@ +#!/usr/bin/python + +import os, time +from django.core.management import call_command + +up = False +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sandbox.settings") + +while not up: + try: + call_command('syncdb', interactive=False) + up = True + except: + time.sleep(1)