首页 文章

芹菜 Worker 队列

提问于
浏览
0

我目前使用“Celeryd”来运行我的Celery工作人员作为守护进程 . 我的/ etc / default / celeryd文件包含以下内容:

CELERYD_NODES="w1 w2 w3"

这显然开始了三个 Worker 流程 .

如何配置路由以使用此配置?例如

celeryd -c 2 -l INFO -Q import

如果我从命令行运行celery,我可以使用-Q标志指定队列 . 我需要告诉我的w1 worker进程只处理来自“import”队列的任务 .

3 回答

  • 5

    通过在CELERYD_OPTS中提供适当的args,可以使不同的工作者从不同/相同的队列中消耗 .

    请参阅:http://celery.readthedocs.org/en/latest/reference/celery.bin.multi.html

    该链接用于芹菜多文档,但您也可以以相同的方式为您的案例提供参数 .

    # 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
    

    可以用作:

    $ CELERYD_OPTS="--time-limit=300 --concurrency=8 -l INFO -Q:1-3 images,video -Q:4,5 data -Q default -L:4,5 DEBUG"
    

    除非必要,否则不要创建额外的守护进程 .

    希望这可以帮助 .

  • -1

    您可以使用名为 CELERYD_OPTS 的指令添加可选的命令行参数 .

    # Names of nodes to start
    #   most will only start one node:
    CELERYD_NODES="w1 w2 w3"
    
    # Extra command-line arguments to the worker
    CELERYD_OPTS="--time-limit=300 --concurrency=4 -Q import"
    

    但据我所知,此选项将告诉所有工作人员仅使用导入队列 .

    如果您找不到可接受的答案,您可以尝试单独管理员工 .

  • 0

    值得注意的是,例如,您可以将节点名称与CELERYD_OPTS参数一起使用

    CELERYD_OPTS="--time-limit=300 --concurrency=4 --concurrency:w3=8 -Q:w1 import"
    

相关问题