有没有一种方法可以启动 celery worker 并用一个命令击败?我想使用 Fabric 将 celery 添加到我的自动部署过程中。
我当前正在运行:
celery -A prj worker -B
其次是
celery -A prj beat -l info -S django
但是,第一个命令启动了工作程序,并且不允许运行下一个命令(启动节拍),因为出现了工作程序启动消息。
有没有办法避免出现启动消息?或者在一个命令中执行这两项操作?也许甚至有办法从我的 Django 配置启动这些?
谢谢!
最佳答案
Celery 允许您在同一进程中运行工作线程和节拍(主要用于开发目的)。查看celeryworker
的帮助:
> celery worker -h
...
Embedded Beat Options:
-B, --beat Also run the celery beat periodic task scheduler. Please note that there must only be
one instance of this service. .. note:: -B is meant to be used for development
purposes. For production environment, you need to start celery beat separately.
-s SCHEDULE_FILENAME, --schedule-filename SCHEDULE_FILENAME, --schedule SCHEDULE_FILENAME
Path to the schedule database if running with the -B option. Defaults to celerybeat-
schedule. The extension ".db" may be appended to the filename. Apply optimization
profile. Supported: default, fair
--scheduler SCHEDULER
Scheduler class to use. Default is celery.beat.PersistentScheduler
因此,组合命令(包括使用 django
调度程序)如下所示:
celery -A prj worker --beat --scheduler django --loglevel=info
关于Celery worker 并通过一个命令击败负载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42566322/