use celery

This commit is contained in:
j 2010-06-25 13:53:57 +02:00
parent b05f8fdb83
commit a03817ae38
9 changed files with 17 additions and 36 deletions

4
README
View File

@ -19,9 +19,9 @@ installed via apt-get/pip/easy_install in your system path.
Install rabbitmq and carrot:
sudo apt-get install rabbitmq-server
sudo rabbitmqctl add_user pandora password
sudo rabbitmqctl add_user pandora box
sudo rabbitmqctl add_vhost /pandora
sudo rabbitmqctl set_permissions -p /pandora pandora "^pandora-.*" ".*" ".*"
sudo rabbitmqctl set_permissions -p /pandora pandora ".*" ".*" ".*"
update BROKER_* settings in local_settings.py:

View File

@ -1,7 +1,7 @@
# pandora background server
# pandora encoding daemon
#
description "pandora background server"
description "pandora encoding daemon"
start on runlevel [2345]
stop on runlevel [!2345]
@ -10,5 +10,5 @@ respawn
chdir /srv/pandora/pandora
exec /bin/su pandora -s /usr/bin/python2.6 /srv/pandora/pandora/bin/pandora-encoder
exec /bin/su pandora -s /usr/bin/python2.6 /srv/pandora/pandora/bin/pandora-encoding

View File

@ -1,7 +1,7 @@
# pandora background server
# pandora background tasks daemon
#
description "pandora background server"
description "pandora background tasks daemon"
start on runlevel [2345]
stop on runlevel [!2345]
@ -10,5 +10,5 @@ respawn
chdir /srv/pandora/pandora
exec /bin/su pandora -s /usr/bin/python2.6 /srv/pandora/pandora/bin/pandora-backgroundtasks
exec /bin/su pandora -s /usr/bin/python2.6 /srv/pandora/pandora/bin/pandora-tasks

View File

@ -1,22 +0,0 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
import os
from os.path import join, dirname, basename, splitext, exists
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings
from ... import daemon
class Command(BaseCommand):
"""
listen to rabbitmq and execute background task.
"""
help = 'listen to rabbitmq and execute background task.'
args = ''
def handle(self, **options):
daemon.run()

View File

@ -29,7 +29,7 @@ import oxlib
import models
import utils
from daemon import send_bg_message
import tasks
from oxuser.models import getUserJSON
from oxuser.views import api_login, api_logout, api_register, api_contact, api_recover, api_preferences
@ -477,7 +477,7 @@ def api_update(request):
f = models.ArchiveFile.get_or_create(archive, oshash)
f.update(data)
if not f.file.movie:
send_bg_message({'findMovie': f.file.id})
task.findMovie(f.file.id)
#FIXME: only add if it was not in File
else:
f = q[0]

View File

@ -17,5 +17,5 @@ sys.path.append(os.path.join(root_dir, project_module))
from django.core.management import execute_manager
import settings
execute_manager(settings, ['pandora-encoder', 'encoder'])
execute_manager(settings, ['celeryd', 'celeryd', '-Q' 'encoding'])

View File

@ -17,5 +17,5 @@ sys.path.append(os.path.join(root_dir, project_module))
from django.core.management import execute_manager
import settings
execute_manager(settings, ['backgroundtasks', 'backgroundtasks'])
execute_manager(settings, ['celeryd', 'celeryd', '-Q' 'default'])

View File

@ -5,7 +5,7 @@ import os
from os.path import join
SITENAME = 'Pandora'
URL = 'pandora.Oxdb.org'
URL = 'pan.do/ra'
PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__))
@ -33,6 +33,7 @@ DATABASE_PORT = '' # Set to empty string for default. Not used with
#CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
#rabbitmq connection settings
CELERY_RESULT_BACKEND = "database"
BROKER_HOST = "127.0.0.1"
BROKER_PORT = 5672
BROKER_USER = "pandora"
@ -106,6 +107,7 @@ INSTALLED_APPS = (
'django_extensions',
'devserver',
# 'south',
'djcelery',
'app',
'backend',

View File

@ -7,7 +7,8 @@ chardet
simplejson
-e hg+https://django-ajax-filtered-fields.googlecode.com/hg/#egg=django-ajax-filtered-fields
#rabbitmq interface
carrot
-e git+git://github.com/ask/celery.git#egg=celery
django-celery
django_extensions
-e bzr+http://firefogg.org/dev/python-firefogg/#egg=python-firefogg
-e git+git://github.com/dcramer/django-devserver#egg=django_devserver