Django上的芹菜不工作

时间:2015-03-28 00:55:15

标签: django rabbitmq celery

使用Celery发送电子邮件在生产服务器上运行正常。 尝试在本地开发(VM)上使用它并且不起作用。 重启时我得到了这个:

  • 启动Web服务器apache2 [确定]

    • 启动消息代理rabbitmq-server [确定]
    • 启动芹菜任务工作者服务器celeryd [确定]

      开始celeryev ... :没有这样的文件或目录

此外,我在运行页面时在控制台中收到此错误:

错误:[Errno 104]通过对等方重置连接

生产设置:

import djcelery
djcelery.setup_loader()
BROKER_HOST = "127.0.0.1"
BROKER_PORT = 5672   # default RabbitMQ listening port
BROKER_USER = "vs_user"
BROKER_PASSWORD = "user01"
BROKER_VHOST = "vs_vhost"
CELERY_BACKEND = "amqp"  # telling Celery to report the results back to RabbitMQ
CELERY_RESULT_DBURI = ""

我跑的时候:

sudo rabbitmqctl list_vhosts

我明白了:

列出vhosts ......

/

...进行。

我需要在此设置中更改以在本地VM上成功运行它?

更新

vhost和用户肯定不见了,所以我运行了建议的命令。 他们执行正常,但仍然无法正常工作,同样的错误。 它必须是阻止它工作的另一件事, celeryev 是可疑的。 这是我在停止和启动服务器时得到的:

  • 停止Web服务器apache2 ...等待。 [确定]
  • 停止消息代理rabbitmq-server [确定]
  • 停止芹菜任务工作者服务器celeryd start-stop-daemon:警告:未能杀死28006:没有这样的过程                                                                                                                                                                                                                                   [确定]

停止celeryev ...不跑步

  • 启动Web服务器apache2 [确定]
    • 启动消息代理rabbitmq-server [确定]
    • 启动芹菜任务工作者服务器celeryd [确定]

开始celeryev ... :没有这样的文件或目录

追踪(最近一次呼叫最后一次):

 File "/webapps/target/forums/json_views.py", line 497, in _send_forum_notifications
    post_master_json.delay('ForumNotificationEmail', email_params)
  File "/usr/local/lib/python2.6/dist-packages/celery-3.0.25-py2.6.egg/celery/app/task.py", line 357, in delay
    return self.apply_async(args, kwargs)
  File "/usr/local/lib/python2.6/dist-packages/celery-3.0.25-py2.6.egg/celery/app/task.py", line 474, in apply_async
    **options)
  File "/usr/local/lib/python2.6/dist-packages/celery-3.0.25-py2.6.egg/celery/app/amqp.py", line 250, in publish_task
    **kwargs
  File "/usr/local/lib/python2.6/dist-packages/kombu-2.5.16-py2.6.egg/kombu/messaging.py", line 164, in publish
    routing_key, mandatory, immediate, exchange, declare)
  File "/usr/local/lib/python2.6/dist-packages/kombu-2.5.16-py2.6.egg/kombu/connection.py", line 470, in _ensured
    interval_max)
  File "/usr/local/lib/python2.6/dist-packages/kombu-2.5.16-py2.6.egg/kombu/connection.py", line 396, in ensure_connection
    interval_start, interval_step, interval_max, callback)
  File "/usr/local/lib/python2.6/dist-packages/kombu-2.5.16-py2.6.egg/kombu/utils/__init__.py", line 217, in retry_over_time
    return fun(*args, **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/kombu-2.5.16-py2.6.egg/kombu/connection.py", line 246, in connect
    return self.connection
  File "/usr/local/lib/python2.6/dist-packages/kombu-2.5.16-py2.6.egg/kombu/connection.py", line 761, in connection
    self._connection = self._establish_connection()
  File "/usr/local/lib/python2.6/dist-packages/kombu-2.5.16-py2.6.egg/kombu/connection.py", line 720, in _establish_connection
    conn = self.transport.establish_connection()
  File "/usr/local/lib/python2.6/dist-packages/kombu-2.5.16-py2.6.egg/kombu/transport/pyamqp.py", line 115, in establish_connection
    conn = self.Connection(**opts)
  File "/usr/local/lib/python2.6/dist-packages/amqp-1.0.13-py2.6.egg/amqp/connection.py", line 136, in __init__
    self.transport = create_transport(host, connect_timeout, ssl)
  File "/usr/local/lib/python2.6/dist-packages/amqp-1.0.13-py2.6.egg/amqp/transport.py", line 264, in create_transport
    return TCPTransport(host, connect_timeout)
  File "/usr/local/lib/python2.6/dist-packages/amqp-1.0.13-py2.6.egg/amqp/transport.py", line 99, in __init__
    raise socket.error(last_err)
error: timed out

我运行 manage.py celeryev 并让控制台显示工作人员和任务。一切都是空的,只是反复出现连接错误:错误(超时('超时',))。

1 个答案:

答案 0 :(得分:2)

看起来您没有在本地RabbitMQ服务器上设置指定的虚拟主机。

您首先需要添加虚拟主机。

sudo rabbitmqctl add_vhost vs_vhost

接下来,您需要为用户添加权限。

sudo rabbitmqctl set_permissions -p vs_vhost vs_user ".*" ".*" ".*"

另外,请确保您确实设置了用户,否则您可以使用此命令添加一个用户。

sudo rabbitmqctl add_user vs_user user01