]> git.parisson.com Git - telemeta.git/commitdiff
add a script for waiting available linked container ports, fix worker start
authorGuillaume Pellerin <yomguy@parisson.com>
Thu, 19 Mar 2015 10:57:51 +0000 (11:57 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Thu, 19 Mar 2015 10:57:51 +0000 (11:57 +0100)
docker-compose.yml
examples/deploy/celery_app.sh
examples/deploy/start_app.sh
examples/deploy/wait.sh [new file with mode: 0644]
examples/sandbox/settings.py
telemeta/management/commands/telemeta-timeside-boilerplate.py [new file with mode: 0644]

index 6cb690e1f5fb28d2261bfbc8be7494aa00dfe074..32c8605867e966206ca16d61de84f2a5b236ad33 100644 (file)
@@ -47,7 +47,7 @@ lib:
 home:
   image: debian:wheezy
   volumes:
-    - ./examples/sandbox:/home/telemeta
+    - ./examples/sandbox:/home/sandbox
   command: /bin/true
 
 db:
@@ -57,7 +57,7 @@ db:
     - log
   environment:
     - MYSQL_ROOT_PASSWORD=mysecretpassword
-    - MYSQL_DATABASE=telemeta
+    - 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/Telemeta/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/Telemeta/examples/deploy/celery_app.sh
+  links:
+    - rabbitmq
+    - db
+    - app
 
 nginx:
   image: nginx
index a5752d4293ea87a772df78da7ee95712bee4831d..ac1b1c76646e158b646d6ddfb852a26a8cd9dc77 100644 (file)
@@ -1,14 +1,12 @@
 #!/bin/sh
 
 # paths
-app_dir='/opt/Telemeta/'
-sandbox_dir='/home/telemeta/'
-manage=$sandbox_dir'manage.py'
+app='/opt/Telemeta/'
+sandbox='/home/sandbox/'
+manage=$sandbox'manage.py'
+wsgi=$sandbox'wsgi.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 2b5deb569edf5ac075ec53f18b22236bfa5b9939..a342403f0171976617870e909ff31a9f63616138 100644 (file)
@@ -1,11 +1,13 @@
 #!/bin/sh
 
 # paths
-app_dir='/opt/Telemeta/'
-sandbox_dir='/home/telemeta/'
-manage=$sandbox_dir'manage.py'
-wsgi=$sandbox_dir'wsgi.py'
-app_static_dir=$app_dir'telemeta/static/'
+app='/opt/Telemeta/'
+static=$app'telemeta/static/'
+sandbox='/home/sandbox/'
+manage=$sandbox'manage.py'
+wsgi=$sandbox'wsgi.py'
+
+sh $app/examples/deploy/wait.sh
 
 # django init
 python $manage syncdb --noinput
@@ -17,7 +19,7 @@ python $manage telemeta-create-admin-user
 pip install watchdog
 
 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
index 97cf812d7a2348ede65c5979adc498214644def2..f2a358302181b54fc123b195571af5b4411b4f31 100644 (file)
@@ -33,7 +33,7 @@ DATABASES = {
         'ENGINE': 'django.db.backends.mysql',  # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
         'USER': 'root',      # Not used with sqlite3.
         'PASSWORD': 'mysecretpassword',  # Not used with sqlite3.
-        'NAME': 'telemeta',
+        'NAME': 'sandbox',
         'HOST': 'db',      # Set to empty string for localhost. Not used with sqlite3.
         'PORT': '3306',      # Set to empty string for default. Not used with sqlite3.
     }
diff --git a/telemeta/management/commands/telemeta-timeside-boilerplate.py b/telemeta/management/commands/telemeta-timeside-boilerplate.py
new file mode 100644 (file)
index 0000000..fbb4f2a
--- /dev/null
@@ -0,0 +1,61 @@
+from optparse import make_option
+from django.conf import settings
+from django.core.management.base import BaseCommand, CommandError
+from django.contrib.auth.models import User
+from django.template.defaultfilters import slugify
+
+import os
+import timeside.core
+from timeside.server.models import *
+from timeside.core.tools.test_samples import generateSamples
+
+
+class Command(BaseCommand):
+    help = "Setup and run a boilerplate for testing"
+    cleanup =  True
+
+    def processor_cleanup(self):
+        for processor in Processor.objects.all():
+            processor.delete()
+
+    def result_cleanup(self):
+        for result in Result.objects.all():
+            result.delete()
+
+    def handle(self, *args, **options):
+        presets = []
+        blacklist =['decoder', 'live', 'gain']
+        processors = timeside.core.processor.processors(timeside.core.api.IProcessor)
+        for proc in processors:
+            trig = True
+            for black in blacklist:
+                if black in proc.id():
+                    trig = False
+            if trig:
+                processor, c = Processor.objects.get_or_create(pid=proc.id())
+                preset, c = Preset.objects.get_or_create(processor=processor, parameters='{}')
+                presets.append(preset)
+
+        media_dir = 'items' + os.sep + 'tests'
+        samples_dir = settings.MEDIA_ROOT + media_dir
+        samples = generateSamples(samples_dir=samples_dir)
+        selection, c = Selection.objects.get_or_create(title='Tests')
+
+        for sample in samples.iteritems():
+            filename, path = sample
+            title = os.path.splitext(filename)[0]
+            path = media_dir + os.sep + filename
+            item, c = Item.objects.get_or_create(title=title, file=path)
+            if not item in selection.items.all():
+                selection.items.add(item)
+            if self.cleanup:
+                for result in item.results.all():
+                    result.delete()
+
+        experience, c = Experience.objects.get_or_create(title='All')
+        for preset in presets:
+            if not preset in experience.presets.all():
+                experience.presets.add(preset)
+
+        task = Task(experience=experience, selection=selection)
+        task.status_setter(2)