docker-compose up <service> does not launch <service> properly

Viewed 332

Context: I have a master-worker system on celery + rabbitmq stack.
System is dockerized( worker service is not presented here )

version: '2'
services:
    rabbit:
        hostname: rabbit
        image: rabbitmq:latest
        environment:
            - RABBITMQ_DEFAULT_USER=admin
            - RABBITMQ_DEFAULT_PASS=mypass
        ports:
            - "5672:5672"

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

When i execute docker-compose up - everything OK! enter image description here

Problems: But I can't use docker-compose up, I need to use docker-compose master and docker-compose worker (two separate commands for worker and master machines). So, when I execute docker-compose master - the container launches, but hangs up!: enter image description here

Research: I have found out, that it hangs up on task submitting:
result = longtime_add.delay(count) Where longtime_add is a task.

Full code: https://github.com/waryak/MastersDiploma/tree/vlad

Also, please, edit the title - I feel, that it needs more clear title

2 Answers

A couple of quick points: (1) I didn't see the expected output messages for the producer broker url that you have in github; (2) I couldn't find where /src/network was added to your pythonpath; and (3) the code that loads the producer broker url in celery.py looks wrong as it is looking for the CONFIG variable and not PRODUCE_BROKER_URL as it is in the variables.env file. The reason that the producer would timeout is if it can't connect to the broker, so you'r eon the right track by printing out the produce and worker broker URLs. It may just be easier for you to try hardcoding the broker_url in the producer first:

from celery.app import Celery
app = Celery(broker_url='amqp://admin:mypass/rabbit:56772')
app.send_task(name='messages.tasks.longtime_add', kwargs={})

I just tried docker-compose up rabbit master and it worked out. That's strange, because i can see no external differences in broker logs or any other logs. Also, docker documentation assured, that all depended services would be launched...

Related