我使用Django 1.9,Celery 3.1.23,Redis 2.10.5 - 该网站在Heroku上。 RabbitMQ用作消息代理(CloudAMQP)。
我的settings.py如下:
CELERY_RESULT_BACKEND = os.environ['REDIS_URL']
BROKER_URL = 'amqp://xxx:yyyyyy@salamander.rmq.cloudamqp.com/xxx'
BROKER_POOL_LIMIT = 1
BROKER_CONNECTION_MAX_RETRIES = 100
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = "json"
CELERY_RESULT_SERIALIZER = ['json']
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
if BROKER_URL == "django://":
INSTALLED_APPS += ("kombu.transport.django",)
我总是收到以下错误消息:
Mar 16 14:59:38 terradiem app/worker.1: [2017-03-16 14:59:37,844: ERROR/Beat] beat: Connection error: [Errno 111] Connection refused. Trying again in 32.0 seconds...
Mar 16 14:59:38 terradiem app/worker.1: [2017-03-16 14:59:37,847: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 111] Connection refused.
似乎本地设置(amqp:// guest:** @ 127.0.0.1:5672 //)覆盖了cloudamqp,但我无法确定原因。
这是日志:
Mar 16 15:11:31 myapp heroku/worker.1: Process exited with status 0
Mar 16 15:11:46 myapp heroku/worker.1: Starting process with command `python manage.py celery worker --beat --loglevel=info`
Mar 16 15:11:46 myapp heroku/worker.1: State changed from starting to up
Mar 16 15:11:47 myapp heroku/web.1: Starting process with command `gunicorn terradiem.wsgi --log-file -`
Mar 16 15:11:49 myapp app/web.1: [2017-03-16 14:11:49 +0000] [4] [INFO] Starting gunicorn 19.6.0
Mar 16 15:11:50 myapp app/web.1: [2017-03-16 14:11:49 +0000] [4] [INFO] Listening at: http://0.0.0.0:16874 (4)
Mar 16 15:11:50 myapp app/web.1: [2017-03-16 14:11:49 +0000] [4] [INFO] Using worker: sync
Mar 16 15:11:50 myapp app/web.1: [2017-03-16 14:11:49 +0000] [10] [INFO] Booting worker with pid: 10
Mar 16 15:11:50 myapp app/worker.1: -------------- celery@XXXX-XXXX-XXXX-XXXX-XXXXv3.1.23 (Cipater)
Mar 16 15:11:50 myapp app/worker.1: ---- **** -----
Mar 16 15:11:50 myapp app/worker.1: --- * *** * -- Linux-3.13.0-112-generic-x86_64-with-debian-jessie-sid
Mar 16 15:11:50 myapp app/worker.1: -- * - **** ---
Mar 16 15:11:50 myapp app/worker.1: - ** ---------- [config]
Mar 16 15:11:50 myapp app/worker.1: - ** ---------- .> app: __main__:0x7f15b9bd27d0
Mar 16 15:11:50 myapp app/worker.1: - ** ---------- .> transport: amqp://guest:**@localhost:5672//
Mar 16 15:11:50 myapp app/worker.1: - ** ---------- .> results: disabled://
Mar 16 15:11:50 myapp app/worker.1: - *** --- * --- .> concurrency: 8 (prefork)
Mar 16 15:11:50 myapp app/worker.1: -- ******* ----
Mar 16 15:11:50 myapp app/worker.1: --- ***** ----- [queues]
Mar 16 15:11:50 myapp app/worker.1: -------------- .> celery exchange=celery(direct) key=celery
Mar 16 15:11:50 myapp app/worker.1: [tasks]
Mar 16 15:11:50 terradiem app/worker.1: . fileupload.views.create_thumbnail
你知道为什么Django不会使用我的设置吗?