]> git.parisson.com Git - timeside.git/commitdiff
add a wait script for better composition sequencing
authorGuillaume Pellerin <yomguy@parisson.com>
Thu, 19 Mar 2015 11:35:17 +0000 (12:35 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Thu, 19 Mar 2015 11:35:17 +0000 (12:35 +0100)
docker-compose-mysql.yml
examples/deploy/celery_app.sh
examples/deploy/start_app.sh
examples/deploy/wait.sh [new file with mode: 0644]

index 9f11f79d00e76d2f169b42fedc7affc8773f17fc..b051292566657c33764f95cd9345bb98a839a645 100644 (file)
@@ -47,7 +47,7 @@ lib:
 home:
   image: debian:wheezy
   volumes:
-    - ./examples/sandbox:/home/timeside
+    - ./examples/sandbox:/home/sandbox
   command: /bin/true
 
 db:
@@ -57,7 +57,7 @@ db:
     - log
   environment:
     - MYSQL_ROOT_PASSWORD=mysecretpassword
-    - MYSQL_DATABASE=timeside
+    - MYSQL_DATABASE=sandbox
     - MYSQL_USER=root
     - MYSQL_PASSWORD=mysecretpassword
 
@@ -68,15 +68,6 @@ rabbitmq:
   expose:
     - "5672"
 
-worker:
-  build: .
-  volumes_from:
-    - home
-  command: /bin/sh /opt/TimeSide/examples/deploy/celery_app.sh
-  links:
-    - rabbitmq
-    - db
-
 app:
   build: .
   volumes:
@@ -93,7 +84,16 @@ app:
   links:
     - rabbitmq
     - db
-    - worker
+
+worker:
+  build: .
+  volumes_from:
+    - app
+  command: /bin/sh /opt/TimeSide/examples/deploy/celery_app.sh
+  links:
+    - rabbitmq
+    - db
+    - app
 
 nginx:
   image: nginx
index c09ad06e4fc32a51cba2b9c3b7b35eccab33ff33..8be32e159ee63cb2263815f26c8f3c5a8e83c7d1 100644 (file)
@@ -1,14 +1,11 @@
 #!/bin/sh
 
 # paths
-app_dir='/opt/TimeSide/'
-sandbox_dir='/home/timeside/'
-manage=$sandbox_dir'manage.py'
+app='/opt/TimeSide/'
+sandbox='/home/sandbox/'
+manage=$sandbox'manage.py'
 
-python $manage syncdb --noinput
-python $manage migrate --noinput
-python $manage collectstatic --noinput
-python $manage timeside-create-admin-user
+sh $app/examples/deploy/wait.sh
 
 # Starting celery worker with the --autoreload option will enable the worker to watch for file system changes
 # This is an experimental feature intended for use in development only
index cf843472732e034b1376239ca5888d1708b84f88..94ff7c1397a215da13d35050dc8a80949a46ce5a 100644 (file)
@@ -1,18 +1,13 @@
 #!/bin/sh
 
 # paths
-app_dir='/opt/TimeSide/'
-sandbox_dir='/home/timeside/'
-manage=$sandbox_dir'manage.py'
-wsgi=$sandbox_dir'wsgi.py'
-app_static_dir=$app_dir'timeside/player/static/'
+app='/opt/TimeSide/'
+static=$app'timeside/static/'
+sandbox='/home/sandbox/'
+manage=$sandbox'manage.py'
+wsgi=$sandbox'wsgi.py'
 
-# Copy Sandbox in /home/timeside
-#  this is not needed for TimeSide but for Timeside-diadems
-# cp -uR /opt/TimeSide/examples/sandbox/* /home/timeside/
-
-# install staging modules
-pip install mysql
+sh $app/examples/deploy/wait.sh
 
 # django init
 python $manage syncdb --noinput
@@ -22,7 +17,7 @@ python $manage timeside-create-admin-user
 
 # static files auto update
 watchmedo shell-command --patterns="*.js;*.css" --recursive \
-    --command='python '$manage' collectstatic --noinput' $app_static_dir &
+    --command='python '$manage' collectstatic --noinput' $static &
 
 # app start
-uwsgi --socket :8000 --wsgi-file $wsgi --chdir $sandbox_dir --master --processes 4 --threads 2 --py-autoreload 3
+uwsgi --socket :8000 --wsgi-file $wsgi --chdir $sandbox --master --processes 4 --threads 2 --py-autoreload 3
diff --git a/examples/deploy/wait.sh b/examples/deploy/wait.sh
new file mode 100644 (file)
index 0000000..a3341e0
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+apt-get install -y --force-yes netcat
+
+set -e
+
+host=$(env | grep _TCP_ADDR | cut -d = -f 2)
+port=$(env | grep _TCP_PORT | cut -d = -f 2)
+
+echo -n "waiting for TCP connection to $host:$port..."
+
+while ! nc -w 1 $host $port 2>/dev/null
+do
+  echo -n .
+  sleep 1
+done
+
+echo 'ok'
\ No newline at end of file