【问题标题】:Using supervisor and gunicorn to start up django-celery processes?使用主管和 gunicorn 启动 django-celery 进程?
【发布时间】:2017-10-09 18:49:51
【问题描述】:

混乱!

使用主管很容易启动 django,如下所示 - 基于我找到的教程:

supervisord.conf:

[program:gunicorn]
command=/home/me/.virtualenvs/app/bin/gunicorn app.wsgi:application --bind 127.0.0.1:8000 ;

然而 celery 似乎需要自己的启动方式:

celery -A app worker -l info 

所以在我的无知/困惑中,我似乎必须从 Gunicorn 或 Celery 开始。显然我很困惑,因为毫无疑问,很多人在主管中使用芹菜。

我哪里错了?我如何使用 supervisor 在 Gunicorn 中启动一个 celery-django 应用程序?

【问题讨论】:

  • 我在这里猜测您的实际问题,所以如果这没有帮助,请告诉我。这将告诉你在哪里可以找到 celery 命令:type -a celery。通常它在你的 virtualenv 的 bin 文件夹中。您不需要 gunicorn 在主管内运行 celery。
  • 自从问了这个问题,我的“误会”有了一点进步。运行 celery worker 会在自身内部创建一个 django 实例吗?否则我已经启动了 gunicorn/django 实例和 celery 实例,假设 django 实例与 celery 实例合作。

标签: python django celery gunicorn supervisord


【解决方案1】:
celery -A app worker -l info

上面的命令会在前台启动一个 celery worker 的实例。

an example supervisor configuration available in the celery source 如果你想使用supervisor 来守护worker。 Supervisor 可以管理多个程序,因此您可以根据需要使用它来管理 gunicorn 和一个或多个 celery worker 实例。

celery worker 作为自己的进程运行。它连接到代理(例如 redis)并等待您配置的队列上的任务。这些任务将从您的 django 应用发送。

以下教程很好地解释了如何配置 supervisor 来启动和管理 celery worker。 https://realpython.com/blog/python/asynchronous-tasks-with-django-and-celery/

【讨论】:

  • 非常感谢您会检查的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-21
  • 2019-06-09
  • 2014-03-23
  • 2016-04-24
  • 2015-05-01
  • 2017-08-16
相关资源
最近更新 更多