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
# ------------------------------------------------------------------------------
# RabbitMQ
RABBITMQ_URL=amqp://user:bitnami@rabbitmq:5672/
# Flower
CELERY_FLOWER_USER=!!!SET CELERY_FLOWER_USER!!!
CELERY_FLOWER_PASSWORD=!!!SET CELERY_FLOWER_PASSWORD!!!

View File

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

View File

@ -7,7 +7,7 @@ set -o nounset
{% if cookiecutter.use_celery == 'y' %}
# N.B. If only .env files supported variable expansion...
export CELERY_BROKER_URL="${REDIS_URL}"
export CELERY_BROKER_URL="${RABBITMQ_URL}"
{% endif %}
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
CELERY_BROKER_URL = env("CELERY_BROKER_URL")
# 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
CELERY_ACCEPT_CONTENT = ["json"]
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-task_serializer

View File

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

View File

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