芹菜工人和节拍负荷在一个命令

时间:2017-03-02 21:28:49

标签: celery django-celery celerybeat django-deployment

有没有办法启动芹菜工人并在一个命令中击败?我想在使用Fabric的自动部署过程中添加芹菜。

我目前正在投放:

celery -A prj worker -B

接着是

celery -A prj beat -l info -S django

但是,第一个命令启动了worker,并且不允许运行下一个命令(启动节拍),因为出现了worker启动消息。

有没有办法避免出现启动消息?或者在一个命令中执行这两个操作?也许甚至还有一种方法可以从我的Django配置启动它们?

谢谢!

2 个答案:

答案 0 :(得分:10)

Celery允许您在同一过程中运行工作者并且击败(主要用于开发目的)。查看celery worker的帮助:

> 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

答案 1 :(得分:1)

celery -A proj worker -l info -B