我正在尝试设置 rabbitmq/celery/django-celery/django 以使其具有“防重启”功能,即一切都会自行恢复。一切似乎都很好,除了这个:
当我重新启动时,所有服务都启动了,但似乎 celeryd 在 rabbitmq 之前启动,并且 celerybeat 随后被终止,因为它无法连接(?):
[2011-06-14 00:48:35,128: WARNING/MainProcess] celery@inquire has started.
[2011-06-14 00:48:35,130: INFO/Beat] child process calling self.run()
[2011-06-14 00:48:35,131: INFO/Beat] Celerybeat: Starting...
[2011-06-14 00:48:35,134: ERROR/MainProcess] Consumer: Connection Error: [Errno 111] Connection refused. Trying again in 2 seconds...
[2011-06-14 00:48:35,688: INFO/Beat] process shutting down
[2011-06-14 00:48:35,689: WARNING/Beat] Process Beat:
[2011-06-14 00:48:35,689: WARNING/Beat] Traceback (most recent call last):
...
[2011-06-14 00:48:35,756: WARNING/Beat] File "/home/inquire/inquire.env/lib/python2.6/site-packages/amqplib/client_0_8/transport.py", line 220, in create_transport
[2011-06-14 00:48:35,760: WARNING/Beat] return TCPTransport(host, connect_timeout)
[2011-06-14 00:48:35,761: WARNING/Beat] File "/home/inquire/inquire.env/lib/python2.6/site-packages/amqplib/client_0_8/transport.py", line 58, in __init__
[2011-06-14 00:48:35,761: WARNING/Beat] self.sock.connect((host, port))
[2011-06-14 00:48:35,761: WARNING/Beat] File "<string>", line 1, in connect
[2011-06-14 00:48:35,761: WARNING/Beat] error: [Errno 111] Connection refused
[2011-06-14 00:48:35,761: INFO/Beat] process exiting with exitcode 1
[2011-06-14 00:48:37,137: ERROR/MainProcess] Consumer: Connection Error: [Errno 111] Connection refused. Trying again in 4 seconds...
在 Ubuntu 上,我将带有 apt 的 rabbitmq-server、带有 pip 的 django-celery 安装到我的 virtualenv 中,然后我符号链接了我从https://github.com/ask/celery/tree/master/contrib/debian获得的“celeryd”initscript /etc/init.d 中的/init.d,在 /etc/default/celeryd 中将其配置为使用我的 virtualenv 中的 django celeryd,并通过它使其“防重启”(也许“默认值”是问题?)
update-rc.d celeryd defaults
我没有使用单独的 initscript 运行 celeryd 和 celerybeat,而是将 celeryd 配置为包含 Beat(也许这就是问题所在?):
CELERYD_OPTS="-v 2 -B -s celery -E"
任何指针如何解决这个问题?
如果我
sudo /etc/init.d/celeryd restart
没有投诉:
[2011-06-14 00:54:29,157: WARNING/MainProcess] celery@inquire has started.
[2011-06-14 00:54:29,161: INFO/Beat] child process calling self.run()
[2011-06-14 00:54:29,162: INFO/Beat] Celerybeat: Starting...
但我需要消除对任何手动步骤的需要。