From b8e39074df30805351939f0c8a37b7cc39d54b64 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Tue, 26 Jan 2016 13:26:45 +0100 Subject: [PATCH] no pre-start anymore for the db (hack: waiting for valid syncdb) --- README.rst | 10 +--------- app/deploy/start_app.sh | 3 +++ app/wait.py | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 app/wait.py diff --git a/README.rst b/README.rst index d05c182a..2632dfa3 100644 --- a/README.rst +++ b/README.rst @@ -18,10 +18,6 @@ Run these commands in a terminal:: git clone --recursive git://git.forge.ircam.fr/Manifeste.git cd Manifeste - docker-compose up db - -The last command is needed to initialize the database. Leave the session with CTRL+C and then finally do:: - docker-compose up To restore the backuped database, in another terminal:: @@ -41,10 +37,6 @@ Run these commands in a terminal:: docker-machine ip manifeste git clone --recursive git://git.forge.ircam.fr/Manifeste.git cd Manifeste - docker-compose up db - -The last command is needed to initialize the database. Leave the session with CTRL+C and then finally do:: - docker-compose up Then, in another terminal:: @@ -53,6 +45,6 @@ Then, in another terminal:: cd Manifeste docker-compose run db /srv/backup/restore_db.sh -The 3rd command should give you the IP of the VM. For example, if IP is 192.168.59.103, you should be able to browse the site at http://192.168.59.103:8010/ `More info `_ about using docker and related tools. +The 3rd command should give you the IP of the VM. For example, if IP is 192.168.59.103, you should be able to browse the site at http://192.168.59.103:8010/ diff --git a/app/deploy/start_app.sh b/app/deploy/start_app.sh index 634c0ab2..84b21476 100644 --- a/app/deploy/start_app.sh +++ b/app/deploy/start_app.sh @@ -23,6 +23,9 @@ chown -R $uid:$gid $media # 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) -- 2.39.5