Fix CELERY_BROKER_URL overriden in entrypoint.sh

Closes #1235.
This commit is contained in:
Nikita P. Shupeyko 2018-03-08 18:10:38 +03:00
parent 5543359382
commit 03ee6c78d6
7 changed files with 41 additions and 15 deletions

View File

@ -249,6 +249,11 @@ def remove_envs_and_associated_files():
os.remove('merge_production_dotenvs_in_dotenv.py')
def remove_celery_envs():
os.remove(os.path.join('.envs', '.local', '.celery'))
os.remove(os.path.join('.envs', '.production', '.celery'))
def main():
postgres_user = generate_postgres_user()
set_flags_in_envs(postgres_user)
@ -311,6 +316,8 @@ def main():
if '{{ cookiecutter.use_celery }}'.lower() == 'n':
remove_celery_app()
if '{{ cookiecutter.use_docker }}'.lower() == 'y':
remove_celery_envs()
if '{{ cookiecutter.use_travisci }}'.lower() == 'n':
remove_dottravisyml_file()

View File

@ -0,0 +1,3 @@
# Celery
# ------------------------------------------------------------------------------
CELERY_BROKER_URL=redis://redis:6379/0

View File

@ -0,0 +1,3 @@
# Celery
# ------------------------------------------------------------------------------
CELERY_BROKER_URL=redis://redis:6379/0

View File

@ -7,11 +7,6 @@ set -o nounset
cmd="$@"
export REDIS_URL=redis://redis:6379
{%- if cookiecutter.use_celery == 'y' %}
export CELERY_BROKER_URL="${REDIS_URL}/0"
{%- endif %}
if [ -z "${POSTGRES_USER}" ]; then
# the official postgres image uses 'postgres' as default user if not set explictly.
export POSTGRES_USER=postgres

View File

@ -11,7 +11,7 @@ services:
dockerfile: ./compose/local/django/Dockerfile
depends_on:
- postgres
{% if cookiecutter.use_mailhog == 'y' -%}
{%- if cookiecutter.use_mailhog == 'y' %}
- mailhog
{%- endif %}
volumes:
@ -19,6 +19,9 @@ services:
env_file:
- ./.envs/.local/.django
- ./.envs/.local/.postgres
{%- if cookiecutter.use_celery == 'y' %}
- ./.envs/.local/.celery
{%- endif %}
ports:
- "8000:8000"
command: /start.sh
@ -32,12 +35,16 @@ services:
- postgres_backup_local:/backups
env_file:
- ./.envs/.local/.postgres
{% if cookiecutter.use_mailhog == 'y' %}
{%- if cookiecutter.use_mailhog == 'y' %}
mailhog:
image: mailhog/mailhog:v1.0.0
ports:
- "8025:8025"
{% endif %}{% if cookiecutter.use_celery == 'y' %}
{%- endif %}
{%- if cookiecutter.use_celery == 'y' %}
redis:
image: redis:3.0
@ -49,6 +56,8 @@ services:
{% if cookiecutter.use_mailhog == 'y' -%}
- mailhog
{%- endif %}
env_file:
- ./.envs/.local/.celery
ports: []
command: /start-celeryworker.sh
@ -60,6 +69,9 @@ services:
{% if cookiecutter.use_mailhog == 'y' -%}
- mailhog
{%- endif %}
env_file:
- ./.envs/.local/.celery
ports: []
command: /start-celerybeat.sh
{% endif %}
{%- endif %}

View File

@ -8,6 +8,9 @@ PRODUCTION_DOTENVS_DIR_PATH = os.path.join(ROOT_DIR_PATH, '.envs', '.production'
PRODUCTION_DOTENV_FILE_PATHS = [
os.path.join(PRODUCTION_DOTENVS_DIR_PATH, '.django'),
os.path.join(PRODUCTION_DOTENVS_DIR_PATH, '.postgres'),
{%- if cookiecutter.use_celery == 'y' %}
os.path.join(PRODUCTION_DOTENVS_DIR_PATH, '.celery'),
{%- endif %}
os.path.join(PRODUCTION_DOTENVS_DIR_PATH, '.caddy'),
]
DOTENV_FILE_PATH = os.path.join(ROOT_DIR_PATH, '.env')

View File

@ -16,6 +16,9 @@ services:
env_file:
- ./.envs/.production/.django
- ./.envs/.production/.postgres
{%- if cookiecutter.use_celery == 'y' %}
- ./.envs/.production/.celery
{%- endif %}
command: /gunicorn.sh
postgres:
@ -44,15 +47,15 @@ services:
redis:
image: redis:3.0
{% if cookiecutter.use_celery == 'y' %}
{%- if cookiecutter.use_celery == 'y' %}
celeryworker:
<<: *django
depends_on:
- postgres
- redis
env_file:
- ./.envs/.production/.django
- ./.envs/.production/.postgres
- ./.envs/.production/.celery
command: /start-celeryworker.sh
celerybeat:
@ -61,7 +64,7 @@ services:
- postgres
- redis
env_file:
- ./.envs/.production/.django
- ./.envs/.production/.postgres
- ./.envs/.production/.celery
command: /start-celerybeat.sh
{% endif %}
{%- endif %}