Add rabbitmq

This commit is contained in:
Andrew-Chen-Wang 2020-04-29 16:04:30 -04:00
parent e60084fee1
commit bb111c0329
6 changed files with 22 additions and 7 deletions

View File

@ -11,6 +11,9 @@ REDIS_URL=redis://redis:6379/0
# Celery # Celery
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# RabbitMQ
RABBITMQ_URL=amqp://user:bitnami@rabbitmq:5672/
# Flower # Flower
CELERY_FLOWER_USER=!!!SET CELERY_FLOWER_USER!!! CELERY_FLOWER_USER=!!!SET CELERY_FLOWER_USER!!!
CELERY_FLOWER_PASSWORD=!!!SET CELERY_FLOWER_PASSWORD!!! CELERY_FLOWER_PASSWORD=!!!SET CELERY_FLOWER_PASSWORD!!!

View File

@ -65,6 +65,9 @@ REDIS_URL=redis://redis:6379/0
# Celery # Celery
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# RabbitMQ
RABBITMQ_URL=amqp://user:bitnami@rabbitmq:5672/
# Flower # Flower
CELERY_FLOWER_USER=!!!SET CELERY_FLOWER_USER!!! CELERY_FLOWER_USER=!!!SET CELERY_FLOWER_USER!!!
CELERY_FLOWER_PASSWORD=!!!SET CELERY_FLOWER_PASSWORD!!! CELERY_FLOWER_PASSWORD=!!!SET CELERY_FLOWER_PASSWORD!!!

View File

@ -7,7 +7,7 @@ set -o nounset
{% if cookiecutter.use_celery == 'y' %} {% if cookiecutter.use_celery == 'y' %}
# N.B. If only .env files supported variable expansion... # N.B. If only .env files supported variable expansion...
export CELERY_BROKER_URL="${REDIS_URL}" export CELERY_BROKER_URL="${RABBITMQ_URL}"
{% endif %} {% endif %}
if [ -z "${POSTGRES_USER}" ]; then if [ -z "${POSTGRES_USER}" ]; then

View File

@ -273,7 +273,7 @@ if USE_TZ:
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-broker_url # http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-broker_url
CELERY_BROKER_URL = env("CELERY_BROKER_URL") CELERY_BROKER_URL = env("CELERY_BROKER_URL")
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_backend # http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_backend
CELERY_RESULT_BACKEND = CELERY_BROKER_URL CELERY_RESULT_BACKEND = "rpc"
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-accept_content # http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-accept_content
CELERY_ACCEPT_CONTENT = ["json"] CELERY_ACCEPT_CONTENT = ["json"]
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-task_serializer # http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-task_serializer

View File

@ -47,16 +47,18 @@ services:
{%- endif %} {%- endif %}
{%- if cookiecutter.use_celery == 'y' %} {%- if cookiecutter.use_celery == 'y' %}
redis: rabbitmq:
image: redis:5.0 image: 'bitnami/rabbitmq:latest'
container_name: redis container_name: rabbitmq
ports:
- '5672:5672'
celeryworker: celeryworker:
<<: *django <<: *django
image: {{ cookiecutter.project_slug }}_local_celeryworker image: {{ cookiecutter.project_slug }}_local_celeryworker
container_name: celeryworker container_name: celeryworker
depends_on: depends_on:
- redis - rabbitmq
- postgres - postgres
{% if cookiecutter.use_mailhog == 'y' -%} {% if cookiecutter.use_mailhog == 'y' -%}
- mailhog - mailhog
@ -69,7 +71,7 @@ services:
image: {{ cookiecutter.project_slug }}_local_celerybeat image: {{ cookiecutter.project_slug }}_local_celerybeat
container_name: celerybeat container_name: celerybeat
depends_on: depends_on:
- redis - rabbitmq
- postgres - postgres
{% if cookiecutter.use_mailhog == 'y' -%} {% if cookiecutter.use_mailhog == 'y' -%}
- mailhog - mailhog
@ -81,6 +83,8 @@ services:
<<: *django <<: *django
image: {{ cookiecutter.project_slug }}_local_flower image: {{ cookiecutter.project_slug }}_local_flower
container_name: flower container_name: flower
depends_on:
- rabbitmq
ports: ports:
- "5555:5555" - "5555:5555"
command: /start-flower command: /start-flower

View File

@ -50,6 +50,11 @@ services:
image: redis:5.0 image: redis:5.0
{%- if cookiecutter.use_celery == 'y' %} {%- if cookiecutter.use_celery == 'y' %}
rabbitmq:
image: 'bitnami/rabbitmq:latest'
ports:
- '5672:5672'
celeryworker: celeryworker:
<<: *django <<: *django
image: {{ cookiecutter.project_slug }}_production_celeryworker image: {{ cookiecutter.project_slug }}_production_celeryworker