]> git.parisson.com Git - timeside.git/commitdiff
Add a rabbitmq broker and a celery worker (now builing with "docker-compose up")
authorGuillaume Pellerin <yomguy@parisson.com>
Sat, 14 Mar 2015 01:35:01 +0000 (02:35 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Sat, 14 Mar 2015 01:35:01 +0000 (02:35 +0100)
docker-compose.yml
examples/deploy/celery_app.sh [new file with mode: 0644]
examples/deploy/start_app.sh
examples/sandbox/celery_app.py
examples/sandbox/settings.py

index 5067dfe1eb8b28e5a43e33535ae1af11d7363c96..73d1bb10a7288b62a187fd2e7fa2f5eb55ea94c5 100644 (file)
@@ -18,29 +18,26 @@ log:
     - /var/log/uwsgi
   command: /bin/true
 
-# datadb:
-#   image: debian:wheezy
-#   volumes:
-#     - /var/lib/postgresql
-#   command: /bin/true
+lib:
+  image: debian:wheezy
+  volumes:
+    - /var/lib/rabbitmq
+    - /var/lib/postgres
+    - /var/lib/mysql
+  command: /bin/true
+
 
 # db:
 #   image: postgres
 #   volumes_from:
 #     - datadb
 
-nginx:
-  image: nginx
+rabbitmq:
+  image: rabbitmq:3-management
   ports:
-    - "8000:80"
-  volumes:
-    - ./examples/deploy/nginx-app.conf:/etc/nginx/conf.d/default.conf
-  volumes_from:
-    - static
-    - home
-    - log
-  links:
-    - app
+    - "15672:15672"
+  expose:
+    - "5672"
 
 app:
   build: .
@@ -54,4 +51,31 @@ app:
   ports:
     - "9000:9000"
   expose:
-    - "80" #default runserver wsgi port
\ No newline at end of file
+    - "8000" #default runserver wsgi port
+  links:
+    - rabbitmq
+
+worker:
+  image: parisson/timeside
+  volumes:
+    - .:/opt/TimeSide
+  volumes_from:
+    - home
+  command: /bin/sh /opt/TimeSide/examples/deploy/celery_app.sh
+  links:
+    - rabbitmq
+    - app
+
+nginx:
+  image: nginx
+  ports:
+    - "8000:80"
+  volumes:
+    - ./examples/deploy/nginx-app.conf:/etc/nginx/conf.d/default.conf
+  volumes_from:
+    - static
+    - home
+    - log
+  links:
+    - app
+
diff --git a/examples/deploy/celery_app.sh b/examples/deploy/celery_app.sh
new file mode 100644 (file)
index 0000000..f92c6df
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# paths
+app_dir='/opt/TimeSide/'
+sandbox_dir='/home/timeside/'
+manage=$sandbox_dir'manage.py'
+
+# cp -uR /opt/TimeSide/examples/sandbox/* /home/timeside/
+
+echo "YYYYYYYYYYYYYY"
+
+pip install django-celery
+
+python $manage migrate --noinput
+
+# run Celery worker for our project myproject with Celery configuration stored in Celeryconf
+su -c "$manage celery worker -A celery_app"
index 79c34f820d2fc5a3937a2fbc283cf72a36e1495e..0a01c219905ffbdf5556bd3a63937a9671277d56 100644 (file)
@@ -11,6 +11,9 @@ app_static_dir=$app_dir'timeside/player/static/'
 #  this is not needed for TimeSide but for Timeside-diadems
 cp -uR /opt/TimeSide/examples/sandbox/* /home/timeside/
 
+# add some staging modules
+pip install watchdog django-celery
+
 # django init
 python $manage syncdb --noinput
 python $manage migrate --noinput
@@ -18,8 +21,6 @@ python $manage collectstatic --noinput
 python $manage timeside-create-admin-user
 
 # static files auto update
-pip install watchdog
-
 watchmedo shell-command --patterns="*.js;*.css" --recursive \
     --command='python '$manage' collectstatic --noinput' $app_static_dir &
 
index f558ac7043b2e6f56769394a7ac69e079fb7c41a..7e9d7f867c160c0b79feeb556e9a2315fdd9222b 100644 (file)
@@ -15,9 +15,9 @@ app = Celery('sandbox')
 # pickle the object when using Windows.
 app.config_from_object('django.conf:settings')
 app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
-app.conf.update(
-    CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend',
-)
+app.conf.update(
+    CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend',
+)
 
 @app.task(bind=True)
 def debug_task(self):
index 66c666f2c50a9987970629bef2641ba124737a18..7254d785c025104b7f06462ee33830f6dfa7914e 100644 (file)
@@ -27,7 +27,7 @@ DATABASES = {
 
 # Hosts/domain names that are valid for this site; required if DEBUG is False
 # See https://docs.djangoproject.com/en/1.4/ref/settings/#allowed-hosts
-ALLOWED_HOSTS = []
+ALLOWED_HOSTS = ['*']
 
 # SECURITY WARNING: keep the secret key used in production secret!
 SECRET_KEY = 'ghv8us2587n97dq&w$c((o5rj_$-9#d-8j#57y_a9og8wux1h7'
@@ -174,10 +174,10 @@ REST_FRAMEWORK = {
 # One or more gearman servers
 # GEARMAN_SERVERS = ['127.0.0.1']
 
-BROKER_URL = 'amqp://guest:guest@localhost//'
+BROKER_URL = 'amqp://guest:guest@rabbitmq//'
+CELERY_IMPORTS = ("timeside.server.tasks",)
+CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend'
+CELERY_TASK_SERIALIZER = "json"
+CELERY_ACCEPT_CONTENT = ['application/json']
 
-
-# This will make sure the app is always imported when
-# Django starts so that shared_task will use this app.
-CELERY_IMPORTS = ("timeside.server.tasks", )
-from celery_app import app
+from celery_app import app
\ No newline at end of file