[英]Celery - errno 111 connection refused
我的 celery 任务在两者之间停止执行。 我的 rabbitmq 停在中间,然后我需要手动重启它。 上次(15-16 小时前),发生了类似的问题,我做了以下(手动),它又开始工作了。
我重新安装了 rabbitmq 然后它又开始工作了。
sudo apt-get --purge remove raabitmq-server
sudo apt-get install raabitmq-server
现在它再次显示`
Celery - errno 111 connection refused
以下是我的配置。
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
请让我知道我哪里出错了?
我应该如何纠正它?
第2部分
另外,我有多个队列。 我可以在项目目录中运行它,但是在妖魔化时,工人不承担任务。 我仍然需要手动启动 celery 工人。 我怎样才能解压它?
这是我的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
Celeryconfig 已在第 1 部分中提供。
这是我的项目目录结构。
project
|-- main.py
|-- project
| |-- celeryconfig.py
| |-- __init__.py
|-- tasks.py
我怎样才能用队列妖魔化? 我也在CELERYD_OPTS
中提供了队列。
有没有办法动态妖魔化celery中的队列数? 例如:- 我们有CELERY_CREATE_MISSING_QUEUES = True
用于创建丢失的队列。 是否有类似于守护进程 celery 队列的东西?
from .celery import app as celery_app
__all__ = ('celery_app',)
这通过将它添加到项目根文件夹的__init__.py
文件来解决
不确定你是否已经修好了,但从外观来看,似乎你有很多问题。
首先,检查您的RabbitMQ服务器是否由于某种原因而遇到麻烦。
/var/log/syslog
可能是一个好的起点)。 你没有说你的服务器操作系统,但假设它是Debian / Ubuntu,因为你提到apt-get,这里有一个可能有用的操作系统日志位置列表: https : //help.ubuntu.com/community/LinuxLogFiles 此外,请确保您的RabbitMQ服务器已配置正确的凭据并允许从您的工作人员的位置访问(例如,启用除环回用户以外的连接):这是您需要做的: https : //www.rabbitmq.com/access -control.html
然后,检查您是否使用正确的身份验证凭据配置了您的worker,完整的URL应该类似于以下内容(必须授予用户访问特定虚拟主机的权限,通过RabbitMQ管理界面配置它非常容易https:// www.rabbitmq.com/management.html ):
BROKER_URL = 'amqp://user:pass@host:port/virtualhost' CELERY_RESULT_BACKEND = 'amqp://user:pass@host:port/virtualhost'
最后,尝试在python中追溯异常,希望能为您提供有关错误的其他信息
心连心
ps re。 妖魔化你的芹菜工人,@ budulianin回答是现货!
我怎么能去除它呢?
通常,我为此目的使用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
BTW, CELERY_CREATE_MISSING_QUEUES默认启用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.