From 26ccf9307fb642b5a7afbb9b364dcced619218c2 Mon Sep 17 00:00:00 2001 From: "Nikita P. Shupeyko" Date: Wed, 4 Apr 2018 13:42:01 +0300 Subject: [PATCH] Fix REDIS_URL missing Fixes #1570. --- {{cookiecutter.project_slug}}/.envs/.local/.django | 7 +++---- .../.envs/.production/.django | 10 +++++----- .../compose/production/django/entrypoint.sh | 3 +++ .../config/settings/production.py | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/{{cookiecutter.project_slug}}/.envs/.local/.django b/{{cookiecutter.project_slug}}/.envs/.local/.django index e0d21567..8aa9a994 100644 --- a/{{cookiecutter.project_slug}}/.envs/.local/.django +++ b/{{cookiecutter.project_slug}}/.envs/.local/.django @@ -1,8 +1,7 @@ # General # ------------------------------------------------------------------------------ USE_DOCKER=yes -{% if cookiecutter.use_celery == "y" %} -# Celery + +# Redis # ------------------------------------------------------------------------------ -CELERY_BROKER_URL=redis://redis:6379/0 -{% endif %} +REDIS_URL=redis://redis:6379/0 diff --git a/{{cookiecutter.project_slug}}/.envs/.production/.django b/{{cookiecutter.project_slug}}/.envs/.production/.django index 934d03db..2e9eefea 100644 --- a/{{cookiecutter.project_slug}}/.envs/.production/.django +++ b/{{cookiecutter.project_slug}}/.envs/.production/.django @@ -16,11 +16,7 @@ DJANGO_SECURE_SSL_REDIRECT=False MAILGUN_API_KEY= DJANGO_SERVER_EMAIL= MAILGUN_DOMAIN= -{% if cookiecutter.use_celery == "y" %} -# Celery -# ------------------------------------------------------------------------------ -CELERY_BROKER_URL=redis://redis:6379/0 -{% endif %} + # AWS # ------------------------------------------------------------------------------ DJANGO_AWS_ACCESS_KEY_ID= @@ -43,3 +39,7 @@ WEB_CONCURRENCY=4 # ------------------------------------------------------------------------------ DJANGO_SENTRY_DSN= {% endif %} + +# Redis +# ------------------------------------------------------------------------------ +REDIS_URL=redis://redis:6379/0 diff --git a/{{cookiecutter.project_slug}}/compose/production/django/entrypoint.sh b/{{cookiecutter.project_slug}}/compose/production/django/entrypoint.sh index 67302e2b..0e0121c2 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/entrypoint.sh +++ b/{{cookiecutter.project_slug}}/compose/production/django/entrypoint.sh @@ -7,6 +7,9 @@ set -o nounset cmd="$@" +# N.B. If only .env files supported variable expansion... +export CELERY_BROKER_URL="${REDIS_URL}" + if [ -z "${POSTGRES_USER}" ]; then base_postgres_image_default_user='postgres' export POSTGRES_USER="${base_postgres_image_default_user}" diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index 121cdcd9..236cecbf 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -21,7 +21,7 @@ DATABASES['default']['CONN_MAX_AGE'] = env.int('CONN_MAX_AGE', default=60) # no CACHES = { 'default': { 'BACKEND': 'django_redis.cache.RedisCache', - 'LOCATION': f'{env("REDIS_URL", default="redis://127.0.0.1:6379")}/{0}', + 'LOCATION': env('REDIS_URL'), 'OPTIONS': { 'CLIENT_CLASS': 'django_redis.client.DefaultClient', # Mimicing memcache behavior.