我不能让我的芹菜工人经常听默认队列.
芹菜不断退出.
$: docker-compose up
Starting tasker_rabbitmq_1
Starting tasker_celery_1
Attaching to tasker_rabbitmq_1,tasker_celery_1
tasker_celery_1 exited with code 1
rabbitmq_1 |
rabbitmq_1 | RabbitMQ 3.6.1. Copyright (C) 2007-2016 Pivotal Software,Inc.
rabbitmq_1 | ## ## Licensed under the MPL. See http://www.rabbitmq.com/
rabbitmq_1 | ## ##
rabbitmq_1 | ########## Logs: /var/log/rabbitmq/rabbit@0bcd2c4762eb.log
rabbitmq_1 | ###### ## /var/log/rabbitmq/rabbit@0bcd2c4762eb-sasl.log
rabbitmq_1 | ##########
rabbitmq_1 | Starting broker... completed with 6 plugins.
我正在尝试构建一个具有单独作业层的应用程序作为单独部署的作业容器.
所以架构是:
> EBS上的Web / App层(Django)
> Jobs Layer:Celery RabbitMQ作为Docker容器
这就是我所拥有的:
文件夹结构:
-tasker
-tasker
-tasks.py
-celeryconfig.py
- __init__.py
-Dockerfile
-docker-compose.yml
-requirements.txt
tasks.py:
from celery import Celery
from celery import task
celery = Celery('tasks',broker='amqp://guest@localhost//')
import os
@celery.task
def add(x,y):
return x + y
Dockerfile:
FROM python:3.4
ENV PYTHONBUFFERED 1
WORKDIR /tasker
ADD requirements.txt /tasker/
RUN pip install -r requirements.txt
ADD . /tasker/
泊坞窗,compose.yml:
rabbitmq:
image: tutum/rabbitmq
environment:
- RABBITMQ_PASS=mypass
ports:
- "5672:5672"
- "15672:15672"
celery:
build: .
command: celery worker --app=tasker.tasks
volumes:
- .:/tasker
links:
- rabbitmq:rabbit
最佳答案
1)将celery安装到python Docker镜像或使用https://hub.docker.com/r/library/celery/
原文链接:https://www.f2er.com/docker/436082.html2)在行中输入密码为rabbitmq添加完整地址:
celery = Celery(‘tasks’,broker =’amqp:// guest:mypass @ rabbit //’)