python – 芹菜多里面的docker容器

我在Docker容器中有芹菜的python应用程序.我想要几个工人队列不同.
例如:

celery worker -c 3 -Q queue1
celery worker -c 7 -Q queue2,queue3

但我不会在docker compose中这样做.我发现芹菜多了.我试过用它.

version: '3.2'
services:
  app:
    image: "app"
    build:
      context: .
    networks:
      - net
    ports:
      - 5004:5000
    stdin_open: true
    tty: true
    environment:
      FLASK_APP: app/app.py
      FLASK_DEBUG: 1
    volumes:
      - .:/home/app
  app__celery:
    image: "app"
    build:
      context: .
    command: sh -c 'celery multi start 2 -l INFO -c:1 3 -c:2 7 -Q:1 queue1 -Q:2 queue2,queue3'

但我明白了……

app__celery_1  |    > celery1@1ab37081acb9: OK
app__celery_1  |    > celery2@1ab37081acb9: OK
app__celery_1 exited with code 0

我的芹菜容器关闭了.怎么不让他靠近他的原木?

UPD:Celery多创建了后台进程.如何在前景中启动芹菜多?

最佳答案
我这样做了.我用supervisord代替芹菜多. Supervisord从前景开始,我的容器没有关闭.

command: supervisord -c supervisord.conf

我将所有队列添加到supervisord.con

[program:celery]
command = celery worker -A app.celery.celery -l INFO -c 3 -Q q1
directory = %(here)s
startsecs = 5
autostart = true
autorestart = true
stopwaitsecs = 300
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0

[program:beat]
command = celery -A app.celery.celery beat -l INFO --pidfile=/tmp/beat.pid
directory = %(here)s
startsecs = 5
autostart = true
autorestart = true
stopwaitsecs = 300
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0

[supervisord]
loglevel = info
nodaemon = true
pidfile = /tmp/supervisord.pid
logfile = /dev/null
logfile_maxbytes = 0

转载注明原文:python – 芹菜多里面的docker容器 - 代码日志