【问题标题】:multiple workers and multiple queues on celery django daemoncelery django 守护进程上的多个工作人员和多个队列
【发布时间】:2014-05-29 12:51:45
【问题描述】:

我正在使用 celery-django 在我的站点后端对任务进行排队。 我正在尝试创建一个设置,其中有两个名为“low”和“high”的队列以及两个工人 W1 和 W2。 我希望他们通过以下方式使用队列中的任务:

W1

W2

通常可以这样。

打开终端1并输入 $celery worker -n W1 -Q low,high

打开终端2并输入 $celery worker -n W2 -Q high

但是我试图通过 celeryd 守护进程来做同样的事情。

我正在按照链接中给出的步骤进行操作:http://celery.readthedocs.org/en/latest/tutorials/daemonizing.html#example-configuration 但是可用的选项似乎不足以满足要求。

请帮助我进行一些我不知道的配置,这可以使它成为可能。除非真的有必要,否则我宁愿不运行多个守护进程或使用其他工具,例如 supervisord(也许您也可以就此向我提出建议)。

【问题讨论】:

    标签: django celery daemon django-celery celeryd


    【解决方案1】:

    您可以使用CELERYD_OPTS 选项传递-Q 参数,类似于Celery reference 中的示例:

    # Advanced example starting 10 workers in the background:
    #   * Three of the workers processes the images and video queue
    #   * Two of the workers processes the data queue with loglevel DEBUG
    #   * the rest processes the default' queue.
    $ celery multi start 10 -l INFO -Q:1-3 images,video -Q:4,5 data
        -Q default -L:4,5 DEBUG
    
    # You can show the commands necessary to start the workers with
    # the 'show' command:
    $ celery multi show 10 -l INFO -Q:1-3 images,video -Q:4,5 data
        -Q default -L:4,5 DEBUG
    

    【讨论】:

    • 如果我将节点命名为CELERYD_NODES="w1 w2 w3 w4 w5" 而不是使用-c 4,我还能使用-Q:1-3 的语法吗?
    【解决方案2】:

    您可以在 CELERY_NODES 中指定多个节点并将节点名称传递给 CELERYD_OPTS 参数,例如:

    CELERY_NODES="W1 W2"
    CELERYD_OPTS="-Q:W1 low,high -Q:W2 high"
    

    【讨论】:

      猜你喜欢
      • 2014-08-23
      • 2020-01-28
      • 1970-01-01
      • 2016-10-07
      • 1970-01-01
      • 2013-02-18
      • 2018-07-18
      • 2013-02-28
      • 2014-11-24
      相关资源
      最近更新 更多