Docker上的芹菜 兔子



我正在尝试遵循本教程如何在10分钟内用芹菜和兔子构建docker群集。

遵循教程,尽管我确实更改了以下文件。我的docker-compose.yml文件如下:

version: '2'                                                                    
services:
    rabbit:
    hostname: rabbit
    image: rabbitmq
    environment:
        - RABBITMQ_DEFAULT_USER=user                           
        - RABBITMQ_DEFAULT_PASS=pass                          
        - HOSTNAME=rabbitmq                                     
        - RABBITMQ_NODENAME=rabbitmq 
    ports: 
        - "5672:5672"  # we forward this port because it's useful for debugging
        - "15672:15672"  # here, we can access rabbitmq management plugin                                    

worker:
    build:
    context: .                                              
    dockerfile: Dockerfile                                  
    volumes:                                                        
        - .:/app                                                
    links:                                                          
        - rabbit                                                
    depends_on:                                                     
        - rabbit                              

test_celery/celery.py

from __future__ import absolute_import, unicode_literals
from celery import Celery                                                       
app = Celery('test_celery',broker='amqp://user:pass@rabbit:5672//',backend='rpc://', include=['test_celery.tasks'])

Dockerfile

FROM python:3.6       
ADD requirements.txt /app/requirements.txt  
ADD ./test_celery /app/ 
WORKDIR /app/   
RUN pip install -r requirements.txt  
ENTRYPOINT celery -A test_celery worker --loglevel=info

我使用以下命令运行代码(我的OS是Ubuntu 16.04(:

sudo docker-compose build   
sudo docker-compose scale worker=5 
sudo docker-compose up

屏幕上的输出看起来像这样:

rabbit_1  | closing AMQP connection <0.501.0> (172.19.0.6:60470 -> 172.19.0.7:5672, vhost: '/', user: 'admin'):
rabbit_1  | client unexpectedly closed TCP connection
rabbit_1  | 
rabbit_1  | =WARNING REPORT==== 8-Jun-2017::03:34:15 ===
rabbit_1  | closing AMQP connection <0.479.0> (172.19.0.6:60468 -> 172.19.0.7:5672, vhost: '/', user: 'admin'):
rabbit_1  | client unexpectedly closed TCP connection
rabbit_1  | 
rabbit_1  | =WARNING REPORT==== 8-Jun-2017::03:34:15 ===
rabbit_1  | closing AMQP connection <0.366.0> (172.19.0.4:44754 -> 172.19.0.7:5672, vhost: '/', user: 'admin'):
rabbit_1  | client unexpectedly closed TCP connection
rabbit_1  | 
rabbit_1  | =WARNING REPORT==== 8-Jun-2017::03:34:15 ===
rabbit_1  | closing AMQP connection <0.359.0> (172.19.0.4:44752 -> 172.19.0.7:5672, vhost: '/', user: 'admin'):
rabbit_1  | client unexpectedly closed TCP connection
worker_1  | [2017-06-08 03:34:19,138: INFO/MainProcess] missed heartbeat from celery@f77048a9d801
worker_1  | [2017-06-08 03:34:24,140: INFO/MainProcess] missed 
heartbeat from celery@79aa2323a472
worker_1  | [2017-06-08 03:34:24,141: INFO/MainProcess] missed heartbeat from celery@93af751ed1b5

然后在同一目录中我运行

python -m test_celery.run_tasks

和此输出给我:

我不确定如何修复和获取与教程相同的输出的kombu.exceptions.OperationalError: timed out错误。

作为输出和错误报告,"客户端出乎意料地关闭的TCP连接"," kombu.exceptions.operationalerror:Timeed Out",看来RabbitMQ并没有按预期开始。您可以运行命令" Docker PS -A"来检查兔容器的状态是什么?如果退出," Docker Logs Container-ID"将打印出兔容器的日志。

相关内容

  • 没有找到相关文章

最新更新