Pip*_*eek 2 python django celery supervisord gunicorn
困惑!
使用主管启动 django 很容易,如下所示 - 基于我找到的教程:
Supervisord.conf:
[program:gunicorn]
command=/home/me/.virtualenvs/app/bin/gunicorn app.wsgi:application --bind 127.0.0.1:8000 ;
Run Code Online (Sandbox Code Playgroud)
然而 celery 似乎需要它自己的启动方法:
celery -A app worker -l info
Run Code Online (Sandbox Code Playgroud)
因此,在我的无知/困惑中,看来我必须从 Gunicorn 或 Celery 开始。显然我很困惑,因为毫无疑问许多人在 Supervisor 中使用 celery 。
我哪里错了?如何使用 Supervisor 在 Gunicorn 中启动 celery-django 应用程序?
小智 5
celery -A app worker -l info
Run Code Online (Sandbox Code Playgroud)
上面的命令将在前台启动 celery Worker 的实例。
如果您想使用主管来守护工作程序,则celery 源中提供了一个示例主管配置。Supervisor 可以管理多个程序,因此您可以使用它来管理 Gunicorn 和一个或多个 celery Worker 实例(如果您愿意)。
celery 工作进程作为自己的进程运行。它连接到代理(例如 Redis)并等待您配置的队列上的任务。这些任务将从您的 django 应用程序发送。
以下教程很好地解释了如何配置 Supervisor 来启动和管理 celery Worker。https://realpython.com/blog/python/asynchronous-tasks-with-django-and-celery/