A
A
Abdulla Mursalov2016-05-31 17:31:17
Django
Abdulla Mursalov, 2016-05-31 17:31:17

How to run celery worker in docker with supervisord?

Hello!
I'm trying to run two containers, the broker for celery works in the first one, the second one will have django, uwsgi, celery.
In general, I would like to run celery in a separate container using the official image, it is not clear how the structure of such an application will look like. Anyway. I'm trying to start a django dev server and a worker using supervisord. Django starts, supervisor throws an error:

django      | 2016-05-31 14:23:43,685 INFO spawned: 'celery' with pid 28
django      | 2016-05-31 14:23:44,198 INFO exited: celery (exit status 1; not expected)
django      | 2016-05-31 14:23:47,212 INFO spawned: 'celery' with pid 32
django      | 2016-05-31 14:23:47,760 INFO exited: celery (exit status 1; not expected)
django      | 2016-05-31 14:23:48,765 INFO gave up: celery entered FATAL state, too many start retries too quickly

docker-compose.yml
version: '2'

services:
  
  rabbitmq:
    container_name: rabbitmq
    image: rabbitmq
    environment:
      - RABBITMQ_DEFAULT_USER=guest
      - RABBITMQ_DEFAULT_PASS=guest
    ports:
      - "5672:5672"
      - "15672:15672"

  django:
    container_name: django
    build: ../proj/
    volumes:
      - /home/user/proj
    command: supervisord -c supervisord.conf
    ports:
      - "8000:8000"
    links:
      - rabbitmq
    depends_on:
      - "rabbitmq"

Dockerfile
FROM ubuntu:16.04

RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y python3 python3-pip build-essential python3-dev supervisor

COPY . /home/user/proj
WORKDIR /home/user/proj

RUN pip3 install -r requirements.txt \
 && python3 manage.py collectstatic --no-input \
 && python3 manage.py makemigrations \
 && python3 manage.py migrate

supervisord.conf
[supervisord]
nodaemon=true

[program:django]
command=python3 manage.py runserver 0.0.0.0:8000

[program:celery]
command=celery worker -A proj --loglevel=info

From the container logs, it can be seen that rabbitmq starts later, despite the depends_on key. In general, what to do? As soon as I did not twist the configs, the error is always the same.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gasoid, 2016-05-31
@Gasoid

you must first check in jang whether the rebbit works, i.e. as in my example, only I am waiting for the database to start, you will have to wait for
rabbitmq
to start container

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question