从一条线执行两个 celery 工人

Tro*_*gon 5 django celery django-celery django-celery-beat

我正在为我的大学的一个团队开发一个项目,其中我主要从事前端和一些基本的 django 模型的工作,所以我对 django-celery 不太熟悉和雄辩,而且我也没有设置它。起初我们使用了一名芹菜工人,但我必须再添加一名工人,这样我才能完成一个用户故事。

我目前正在运行两个工作人员,每个工作人员在终端中运行一个,如下所示:

exec celery -A my_proj --concurrency=1 worker
exec celery -A my_proj --concurrency=1 worker -B -Q notification
Run Code Online (Sandbox Code Playgroud)

当我运行这两个项目时,我的项目有效,但我需要它们从一行开始。那么:如何将这两个脚本合并到一行中?

到目前为止我已经尝试过这个:

exec celery multi start celery -A my_proj --concurrency=1 notification -A my_proj --concurrency=1 -B -Q notification
Run Code Online (Sandbox Code Playgroud)

但这使我的项目无法正常运行。

任何帮助表示感谢,谢谢!

Vic*_*tor 4

解决方案

celery multi start 2 -A my_proj -c=1 -B:2 -Q:2 notification

上面告诉启动 2 个工作程序和第二个工作程序来处理notification队列并将 celerybeat 嵌入其中

解释

您可以运行以下命令来查看由此产生的命令

celery multi show 2 -A my_proj -c=1 -B:2 -Q:2 notification

输出:

celery worker -A my_proj -c=1
celery worker -A my_proj -c=1 -B -Q notification
Run Code Online (Sandbox Code Playgroud)