在生产中运行Django-Celery [英] Running Django-Celery in Production

查看:153
本文介绍了在生产中运行Django-Celery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经构建了一个Django Web应用程序和一些Django-Piston服务。使用Web界面,用户将某些数据发送到Web服务,该Web服务依次使用Django-celery启动后台任务。



一切正常在开发环境中使用manage.py。现在我试图将它移植到正确的apache服务器上。网络应用程序和Web服务在生产中工作正常,但是我担心这个问题是将celeryd作为一个守护进程启动。根据以下说明: http: //docs.celeryproject.org/en/latest/tutorials/daemonizing.html#running-the-worker-as-a-daemon 我创建了一个celeryconfig.py文件,并将其粘贴到/ usr / bin目录(这是celeryd是我的arch linux服务器上的位置)。

  CELERYD_CHDIR =/ srv / http / ControllerFramework / 
DJANGO_SETTINGS_MODULE =settings
CELERYD =/ srv / http / ControllerFramework / manage.py celeryd

但是,当我尝试从命令行启动celeryd时,会得到以下错误:

 缺少连接字符串!你有
celery.exceptions.ImproperlyConfigured:缺少连接字符串!你有CELERY_RESULT_DBURI设置为真实值吗?

不知道从哪里去。以下是我的settings.py部分,因为它与此问题有关:

  BROKER_HOST =localhost
BROKER_PORT = 5672
BROKER_USER =controllerFramework
BROKER_PASSWORD =******
BROKER_VHOST =localhost


解决方案

所以我最终在django-celery上与项目负责人聊天。几件事情首先,芹菜必须使用'manage.py celeryd'运行。其次,在settings.py文件中,您必须导入djcelery
此导入问题可能会在下一个版本中修复,但现在您必须执行此操作。


I've built a Django web application and some Django-Piston services. Using a web interface a user submits some data which is POSTed to a web service and that web service in turn uses Django-celery to start a background task.

Everything works fine in the development environment using manage.py. Now I'm trying to move this to production on a proper apache server. The web application and web services work fine in production but I'm having serious issues starting celeryd as a daemon. Based on these instructions: http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html#running-the-worker-as-a-daemon I've created a celeryconfig.py file and stuck it in the /usr/bin directory (this is where celeryd is location on my arch linux server).

CELERYD_CHDIR="/srv/http/ControllerFramework/"
DJANGO_SETTINGS_MODULE="settings"
CELERYD="/srv/http/ControllerFramework/manage.py celeryd"

However when I try to start celeryd from the command line I get the following error:

 "Missing connection string! Do you have "
celery.exceptions.ImproperlyConfigured: Missing connection string! Do you have    CELERY_RESULT_DBURI set to a real value?

Not sure where to go from here. Below is my settings.py section as it pertains to this problem:

BROKER_HOST = "localhost"
BROKER_PORT = 5672
BROKER_USER = "controllerFramework"
BROKER_PASSWORD = "******"
BROKER_VHOST = "localhost"

解决方案

So I ended up having a chat with the project lead on django-celery. Couple of things. First off celery must be run using 'manage.py celeryd'. Secondly, in the settings.py file you have to 'import djcelery' This import issue may be fixed in the next version but for now you have to do this.

这篇关于在生产中运行Django-Celery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆