9

celery status在我的生产服务器上运行命令时,出现此错误:

但是,Celery 工作并且工人运行,这是什么错误,为什么我不能运行这个命令?

ubuntu@ip-10-32-9-39:/srv/project/logs/celery$ celery status
Traceback (most recent call last):
  File "/usr/local/bin/celery", line 9, in <module>
    load_entry_point('celery==3.0.11', 'console_scripts', 'celery')()
  File "/usr/local/lib/python2.7/dist-packages/celery/__main__.py", line 14, in main
    main()
  File "/usr/local/lib/python2.7/dist-packages/celery/bin/celery.py", line 946, in main
    cmd.execute_from_commandline(argv)
  File "/usr/local/lib/python2.7/dist-packages/celery/bin/celery.py", line 890, in execute_from_commandline
    super(CeleryCommand, self).execute_from_commandline(argv)))
  File "/usr/local/lib/python2.7/dist-packages/celery/bin/base.py", line 179, in execute_from_commandline
    return self.handle_argv(prog_name, argv[1:])
  File "/usr/local/lib/python2.7/dist-packages/celery/bin/celery.py", line 882, in handle_argv
    return self.execute(command, argv)
  File "/usr/local/lib/python2.7/dist-packages/celery/bin/celery.py", line 857, in execute
    return cls(app=self.app).run_from_argv(self.prog_name, argv)
  File "/usr/local/lib/python2.7/dist-packages/celery/bin/celery.py", line 142, in run_from_argv
    return self(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/celery/bin/celery.py", line 112, in __call__
    ret = self.run(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/celery/bin/celery.py", line 652, in run
    .run('ping', **dict(kwargs, quiet=True, show_body=False))
  File "/usr/local/lib/python2.7/dist-packages/celery/bin/celery.py", line 505, in run
    return self.do_call_method(args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/celery/bin/celery.py", line 527, in do_call_method
    replies = handler(method, *args[1:], **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/celery/bin/celery.py", line 570, in call
    return getattr(i, method)(*args)
  File "/usr/local/lib/python2.7/dist-packages/celery/app/control.py", line 79, in ping
    return self._request('ping')
  File "/usr/local/lib/python2.7/dist-packages/celery/app/control.py", line 54, in _request
    timeout=self.timeout, reply=True))
  File "/usr/local/lib/python2.7/dist-packages/celery/app/control.py", line 260, in broadcast
    channel=channel)
  File "/usr/local/lib/python2.7/dist-packages/kombu/pidbox.py", line 235, in _broadcast
    chan = channel or self.connection.default_channel
  File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 748, in default_channel
    self.connection
  File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 733, in connection
    self._connection = self._establish_connection()
  File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 692, in _establish_connection
    conn = self.transport.establish_connection()
  File "/usr/local/lib/python2.7/dist-packages/kombu/transport/pyamqp.py", line 109, in establish_connection
    heartbeat=conninfo.heartbeat)
  File "/usr/local/lib/python2.7/dist-packages/amqp/connection.py", line 136, in __init__
    self.transport = create_transport(host, connect_timeout, ssl)
  File "/usr/local/lib/python2.7/dist-packages/amqp/transport.py", line 250, in create_transport
    return TCPTransport(host, connect_timeout)
  File "/usr/local/lib/python2.7/dist-packages/amqp/transport.py", line 95, in __init__
    raise socket.error, msg
socket.error: [Errno 111] Connection refused

设置...

CELERYD_NODES="w1 w2 w3"

# Where to chdir at start.
CELERYD_CHDIR="/srv/project/"

# How to call "manage.py celeryd_multi"
CELERYD_MULTI="$CELERYD_CHDIR/manage.py celeryd_multi"

# How to call "manage.py celeryctl"
CELERYCTL="$CELERYD_CHDIR/manage.py celeryctl"

# Extra arguments to celeryd
CELERYD_OPTS="--time-limit=300 --concurrency=8"

# %n will be replaced with the nodename.
CELERYD_LOG_FILE="/srv/project/logs/celery/%n.log"
CELERYD_PID_FILE="/srv/project/celery/%n.pid"

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

# Name of the projects settings module.
export DJANGO_SETTINGS_MODULE="project.settings"
4

2 回答 2

16

从 manage.py shell 启动...

sudo python manage.py celery status

这将解决您的问题。

于 2013-04-15T13:59:34.727 回答
5

就我而言,我必须在包含和文件__init__.py的包中的文件中添加以下行:settings.pycelery.py

# -*- coding: utf-8 -*-
from __future__ import absolute_import

# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app

检查http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html以供参考。

于 2016-03-18T09:55:29.017 回答