在生产中运行 Django-Celery

发布于 2024-09-11 12:30:26 字数 1168 浏览 3 评论 0原文

我构建了一个 Django Web 应用程序和一些 Django-Piston 服务。用户使用 Web 界面提交一些数据,这些数据被 POST 到 Web 服务,而该 Web 服务又使用 Django-celery 启动后台任务。

使用manage.py 在开发环境中一切正常。现在我正在尝试将其转移到适当的 apache 服务器上的生产环境。 Web 应用程序和 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 时,出现以下错误:

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

不确定从这里去哪里。下面是我的 settings.py 部分,因为它与这个问题有关:

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

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"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故事灯 2024-09-18 12:30:26

所以我最终与 django-celery 的项目负责人进行了交谈。有几件事。首先,celery 必须使用“manage.py celeryd”运行。其次,在 settings.py 文件中,您必须“导入 djcelery”
此导入问题可能会在下一版本中得到解决,但现在您必须执行此操作。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文