简体   繁体   中英

Configuring Celery with Django using mod_wsgi

I'm using Django 1.6 and Celery 3.1 (so not using django-celery). My WSGI file looks like this:

import os
import sys

path = '/code_base/backend/'
if path not in sys.path:
    sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'my_django_project.settings.production'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Starting the Apache server everything works as expected as if I was running manage.py runserver . This is fine for my webserver, but what configuration do I need when I want the server to be a worker instead (similar to celery -A my_django_project worker -l info )?

Usually in production you would want to run the worker as a daemon. There are a few ways to achieve that, documented in the Celery Guide , but personally I prefer to run the workers under supervisord .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM