Celery - errno 111连接被拒绝

Pyt*_*ast 22 python rabbitmq celery

我的芹菜任务在两者之间停止执行.我的rabbitmq停在中间,然后我需要手动重启它.上次(15-16小时后),类似的问题发生了,我做了以下(手动),它又开始工作了.

我重新安装了rabbitmq,然后又开始工作了.

sudo apt-get --purge remove raabitmq-server

sudo apt-get install raabitmq-server

现在再次显示`

Celery - errno 111 connection refused
Run Code Online (Sandbox Code Playgroud)

以下是我的配置.

BROKER_URL = 'amqp://'
CELERY_RESULT_BACKEND = 'amqp://'

CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_ACCEPT_CONTENT=['json']
CELERY_TIMEZONE = 'Europe/Oslo'
CELERY_ENABLE_UTC = True

CELERY_CREATE_MISSING_QUEUES = True
Run Code Online (Sandbox Code Playgroud)

请让我知道我哪里出错了?

我该如何纠正呢?

第2部分

另外,我有多个队列.我可以在项目目录中运行它,但是当妖魔化时,工作人员不接受任务.我仍然需要手动启动芹菜工人.我怎么能去除它呢?

这是我的celerd conf.

# Name of nodes to start, here we have a single node
CELERYD_NODES="w1 w2 w3 w4"


CELERY_BIN="/usr/local/bin/celery"

# Where to chdir at start.
CELERYD_CHDIR="/var/www/fractal/parser-quicklook/"

# Python interpreter from environment, if using virtualenv
#ENV_PYTHON="/somewhere/.virtualenvs/MyProject/bin/python"

# How to call "manage.py celeryd_multi"
#CELERYD_MULTI="/usr/local/bin/celeryd-multi"

# How to call "manage.py celeryctl"
#CELERYCTL="/usr/local/bin/celeryctl"

#CELERYBEAT="/usr/local/bin/celerybeat"

# Extra arguments to celeryd
CELERYD_OPTS="--time-limit=300 --concurrency=8  -Q BBC,BGR,FASTCOMPANY,Firstpost,Guardian,IBNLIVE,LIVEMINT,Mashable,NDTV,Pandodaily,Reuters,TNW,TheHindu,ZEENEWS "

# Name of the celery config module, don't change this.
CELERY_CONFIG_MODULE="celeryconfig"

# %n will be replaced with the nodename.
CELERYD_LOG_FILE="/var/log/celery/%n.log"
CELERYD_PID_FILE="/var/run/celery/%n.pid"

# Workers should run as an unprivileged user.
#CELERYD_USER="nobody"
#CELERYD_GROUP="nobody"

# Set any other env vars here too!
PROJET_ENV="PRODUCTION"

# Name of the projects settings module.
# in this case is just settings and not the full path because it will change the dir to
# the project folder first.
CELERY_CREATE_DIRS=1
Run Code Online (Sandbox Code Playgroud)

Celeryconfig已在第1部分中提供.

这是我的proj目录结构.

project
|-- main.py
|-- project
|   |-- celeryconfig.py
|   |-- __init__.py
|-- tasks.py
Run Code Online (Sandbox Code Playgroud)

我怎么能用队列妖魔化?我也提供了队列CELERYD_OPTS.

有没有办法可以动态地妖魔化芹菜中的队列数量?例如: - 我们有CELERY_CREATE_MISSING_QUEUES = True创建丢失的队列.是否有类似于守护芹菜队列的东西?

小智 5

from .celery import app as celery_app

__all__ = ('celery_app',)
Run Code Online (Sandbox Code Playgroud)

通过将其添加到__init__.py项目根文件夹的文件中解决了这个问题


Gre*_*eev 0

我怎样才能解除它?

通常,我使用supervisord来达到这个目的。

这里的配置示例:

[program:celery]
command=/home/my_project/.virtualenvs/my_project/bin/celery worker
    -A my_project.project.celery_app.celery_app
    -n worker-%(process_num)s
    --concurrency=4
    --statedb=/tmp/%(process_num)s.state
    -l INFO

environment=MY_SETTINGS='/etc/my_settings.py'
process_name=%(program_name)s_%(process_num)02d
numprocs_start=1
numprocs=4
user=user_name
directory=/home/my_project
stdout_logfile=/var/log/my_project/celery.log
stderr_logfile=/var/log/my_project/celery_err.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs = 600
killasgroup=true
priority=998
Run Code Online (Sandbox Code Playgroud)

顺便说一句,CELERY_CREATE_MISSING_QUEUES默认启用。