use new celery

This commit is contained in:
j 2019-07-16 12:22:22 +01:00
parent 62fe578f38
commit 46621522b1
4 changed files with 31 additions and 6 deletions

View file

@ -8,9 +8,9 @@ Restart=always
User=pandora User=pandora
Group=pandora Group=pandora
PIDFile=/run/pandora/encoding.pid PIDFile=/run/pandora/encoding.pid
WorkingDirectory=/srv/pandora/pandora WorkingDirectory=/srv/pandora
ExecStart=/srv/pandora/bin/python /srv/pandora/pandora/manage.py \ ExecStart=/srv/pandora/bin/celery \
celery worker \ -A pandora worker \
-Q encoding -n pandora-encoding \ -Q encoding -n pandora-encoding \
--pidfile /run/pandora/encoding.pid \ --pidfile /run/pandora/encoding.pid \
--maxtasksperchild 500 \ --maxtasksperchild 500 \

View file

@ -9,8 +9,8 @@ User=pandora
Group=pandora Group=pandora
PIDFile=/run/pandora/tasks.pid PIDFile=/run/pandora/tasks.pid
WorkingDirectory=/srv/pandora/pandora WorkingDirectory=/srv/pandora/pandora
ExecStart=/srv/pandora/bin/python /srv/pandora/pandora/manage.py \ ExecStart=/srv/pandora/bin/celery \
celery worker \ -A pandora worker \
-Q default,celery -n pandora-default \ -Q default,celery -n pandora-default \
--pidfile /run/pandora/tasks.pid \ --pidfile /run/pandora/tasks.pid \
--maxtasksperchild 1000 \ --maxtasksperchild 1000 \

20
pandora/celery.py Normal file
View file

@ -0,0 +1,20 @@
import os
from celery import Celery
root_dir = os.path.normpath(os.path.abspath(os.path.dirname(__file__)))
os.chdir(root_dir)
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
app = Celery('pandora')
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')
# Load task modules from all registered Django app configs.
app.autodiscover_tasks()

View file

@ -195,7 +195,7 @@ DATABASES = {
} }
#rabbitmq connection settings #rabbitmq connection settings
CELERY_RESULT_BACKEND = 'database' CELERY_RESULT_BACKEND = 'django-db'
CELERY_TASK_SERIALIZER = 'json' CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json'
CELERY_ACCEPT_CONTENT = ['json'] CELERY_ACCEPT_CONTENT = ['json']
@ -297,3 +297,8 @@ ALLOWED_HOSTS = ['*']
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
DATA_UPLOAD_MAX_MEMORY_SIZE = 32 * 1024 * 1024 DATA_UPLOAD_MAX_MEMORY_SIZE = 32 * 1024 * 1024
try:
CELERY_BROKER_URL
except NameError:
CELERY_BROKER_URL = BROKER_URL