django-celery在开发中起作用,在wsgi生产中失败:如何调试? [英] django-celery works in development, fails in wsgi production: How to debug?

查看:145
本文介绍了django-celery在开发中起作用,在wsgi生产中失败:如何调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用django芹菜任务队列,它在开发中工作正常,但在wsgi生产中却没有。更令人沮丧的是,它使用在生产中工作,但我以某种方式打破了它。

I'm using the django celery task queue, and it works fine in development, but not at all in wsgi production. Even more frustrating, it used to work in production, but I somehow broke it.

sudo rabbitmqctl status告诉我,rabbitmq服务器工作中。 django中的所有东西似乎都是peachy:创建对象,并将路由到任务管理器没有问题。但是,他们的状态就像无限期的排队一样。我写了我的代码的方式,一旦从芹菜任务中返回任何东西,就应该切换到错误或准备。所以我假设队列有问题。

"sudo rabbitmqctl status" tells me that the rabbitmq server is working. Everything also seems peachy in django: objects are created, and routed to the task manager without problems. But then their status just stays as "queued" indefinitely. The way I've written my code, they should switch to "error" or "ready," as soon as anything gets returned from the celery task. So I assume there's something wrong with the queue.

两个相关问题:


  • 任何想法可能是什么问题?

  • 如何调试芹菜?在manage.py celeryd命令之外,我不知道如何同步到其内部的工作。是否有日志文件或可以使用的东西?

谢谢!

PS - 我已经看到这个问题,但他似乎想要运行芹菜从manage.py,而不是wsgi。

PS - I've seen this question, but he seems to want to run celery from manage.py, not wsgi.

推荐答案

经过多次搜索,我发现这个问题的最完整的答案是这里。这些方向说明了用于追踪celeryd的微妙官方指示。我将在这里复制要点,但您应该遵循链接,因为Michael已经更详细地解释了一些部分。

After much searching, the most complete answer I found for this question is here. These directions flesh out the skimpy official directions for daemonizing celeryd. I'll copy the gist here, but you should follow the link, because Michael has explained some parts in more detail.

主要思想是你需要三个脚本地点:

The main idea is that you need scripts in three places:


  1. /etc/init.d/celeryd

  2. / etc / default / celeryd

  3. myApp / settings.py

Settings.py与开发模式相同。所以如果已经设置好了,就有四个步骤来转向生产:

Settings.py appears to be the same as in development mode. So if that's already set up, there are four steps to shifting to production:


  1. 下载守护程序脚本,因为它不包括在安装中:
    https://github.com/celery/芹菜/树/ 3.0 / extra / generic-init.d /

  2. 将其放在/etc/init.d/celeryd中

  3. 在/ etc / default / celeryd中创建一个文件,并将变量放在其中:
    http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html#example-django-configuration

  4. 开始脚本

  1. Download the daemon script since it's not included in the installation: https://github.com/celery/celery/tree/3.0/extra/generic-init.d/
  2. Put it in /etc/init.d/celeryd
  3. Make a file in /etc/default/celeryd, and put the variables here into it: http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html#example-django-configuration
  4. Start the script

这解决了我的问题。

这篇关于django-celery在开发中起作用,在wsgi生产中失败:如何调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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