From 641d833be9057c9c97e668f2642df065e6a8fa9c Mon Sep 17 00:00:00 2001 From: Jelmer Draaijer Date: Thu, 15 Feb 2024 10:30:46 +0100 Subject: [PATCH] Remove CELERY_BROKER_URL in favor of REDIS_URL --- .github/workflows/ci.yml | 2 +- docs/deployment-on-heroku.rst | 2 -- docs/developing-locally.rst | 2 -- docs/settings.rst | 1 - tests/test_docker.sh | 1 - {{cookiecutter.project_slug}}/.drone.yml | 2 +- {{cookiecutter.project_slug}}/.github/workflows/ci.yml | 2 +- {{cookiecutter.project_slug}}/.gitlab-ci.yml | 2 +- .../compose/local/django/celery/flower/start | 2 +- .../compose/production/django/Dockerfile | 3 --- .../compose/production/django/celery/flower/start | 2 +- .../compose/production/django/entrypoint | 6 ------ {{cookiecutter.project_slug}}/config/settings/base.py | 2 +- {{cookiecutter.project_slug}}/docs/conf.py | 3 --- 14 files changed, 7 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 91d08b1d..7c3be734 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,7 +92,7 @@ jobs: POSTGRES_PASSWORD: postgres env: - CELERY_BROKER_URL: "redis://localhost:6379/0" + REDIS_URL: "redis://localhost:6379/0" # postgres://user:password@host:port/database DATABASE_URL: "postgres://postgres:postgres@localhost:5432/postgres" diff --git a/docs/deployment-on-heroku.rst b/docs/deployment-on-heroku.rst index fdd953e0..1ef959d1 100644 --- a/docs/deployment-on-heroku.rst +++ b/docs/deployment-on-heroku.rst @@ -85,8 +85,6 @@ it's in the ``Procfile``, but is turned off by default: .. code-block:: bash - # Set the broker URL to Redis - heroku config:set CELERY_BROKER_URL=`heroku config:get REDIS_URL` # Scale dyno to 1 instance heroku ps:scale worker=1 diff --git a/docs/developing-locally.rst b/docs/developing-locally.rst index 16247d08..d7bdb0b0 100644 --- a/docs/developing-locally.rst +++ b/docs/developing-locally.rst @@ -56,8 +56,6 @@ First things first. #. Set the environment variables for your database(s): :: $ export DATABASE_URL=postgres://postgres:@127.0.0.1:5432/ - # Optional: set broker URL if using Celery - $ export CELERY_BROKER_URL=redis://localhost:6379/0 .. note:: diff --git a/docs/settings.rst b/docs/settings.rst index 2be79cbf..dfdccc7c 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -39,7 +39,6 @@ The following table lists settings and their defaults for third-party applicatio ======================================= =========================== ============================================== ====================================================================== Environment Variable Django Setting Development Default Production Default ======================================= =========================== ============================================== ====================================================================== -CELERY_BROKER_URL CELERY_BROKER_URL auto w/ Docker; raises error w/o raises error DJANGO_AWS_ACCESS_KEY_ID AWS_ACCESS_KEY_ID n/a raises error DJANGO_AWS_SECRET_ACCESS_KEY AWS_SECRET_ACCESS_KEY n/a raises error DJANGO_AWS_STORAGE_BUCKET_NAME AWS_STORAGE_BUCKET_NAME n/a raises error diff --git a/tests/test_docker.sh b/tests/test_docker.sh index 9811b4fd..e126c4a1 100755 --- a/tests/test_docker.sh +++ b/tests/test_docker.sh @@ -33,7 +33,6 @@ docker compose -f docker-compose.local.yml run django python manage.py makemessa docker compose -f docker-compose.local.yml run \ -e DJANGO_SECRET_KEY="$(openssl rand -base64 64)" \ -e REDIS_URL=redis://redis:6379/0 \ - -e CELERY_BROKER_URL=redis://redis:6379/0 \ -e DJANGO_AWS_ACCESS_KEY_ID=x \ -e DJANGO_AWS_SECRET_ACCESS_KEY=x \ -e DJANGO_AWS_STORAGE_BUCKET_NAME=x \ diff --git a/{{cookiecutter.project_slug}}/.drone.yml b/{{cookiecutter.project_slug}}/.drone.yml index d6c13e62..20d6fb1b 100644 --- a/{{cookiecutter.project_slug}}/.drone.yml +++ b/{{cookiecutter.project_slug}}/.drone.yml @@ -7,7 +7,7 @@ environment: POSTGRES_DB: 'test_{{ cookiecutter.project_slug }}' POSTGRES_HOST_AUTH_METHOD: trust {%- if cookiecutter.use_celery == 'y' %} - CELERY_BROKER_URL: 'redis://redis:6379/0' + REDIS_URL: 'redis://redis:6379/0' {%- endif %} steps: diff --git a/{{cookiecutter.project_slug}}/.github/workflows/ci.yml b/{{cookiecutter.project_slug}}/.github/workflows/ci.yml index 0d8ed0ca..6bb55506 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/ci.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/ci.yml @@ -57,7 +57,7 @@ jobs: env: {%- if cookiecutter.use_celery == 'y' %} - CELERY_BROKER_URL: 'redis://localhost:6379/0' + REDIS_URL: 'redis://localhost:6379/0' {%- endif %} # postgres://user:password@host:port/database DATABASE_URL: 'postgres://postgres:postgres@localhost:5432/postgres' diff --git a/{{cookiecutter.project_slug}}/.gitlab-ci.yml b/{{cookiecutter.project_slug}}/.gitlab-ci.yml index 71216bc7..9c7cd536 100644 --- a/{{cookiecutter.project_slug}}/.gitlab-ci.yml +++ b/{{cookiecutter.project_slug}}/.gitlab-ci.yml @@ -8,7 +8,7 @@ variables: POSTGRES_DB: 'test_{{ cookiecutter.project_slug }}' POSTGRES_HOST_AUTH_METHOD: trust {%- if cookiecutter.use_celery == 'y' %} - CELERY_BROKER_URL: 'redis://redis:6379/0' + REDIS_URL: 'redis://redis:6379/0' {%- endif %} precommit: diff --git a/{{cookiecutter.project_slug}}/compose/local/django/celery/flower/start b/{{cookiecutter.project_slug}}/compose/local/django/celery/flower/start index cebb6220..f8377ada 100644 --- a/{{cookiecutter.project_slug}}/compose/local/django/celery/flower/start +++ b/{{cookiecutter.project_slug}}/compose/local/django/celery/flower/start @@ -13,4 +13,4 @@ echo 'Starting flower' exec watchfiles --filter python celery.__main__.main \ --args \ - "-A config.celery_app -b \"${CELERY_BROKER_URL}\" flower --basic_auth=\"${CELERY_FLOWER_USER}:${CELERY_FLOWER_PASSWORD}\"" + "-A config.celery_app -b \"${REDIS_URL}\" flower --basic_auth=\"${CELERY_FLOWER_USER}:${CELERY_FLOWER_PASSWORD}\"" diff --git a/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile b/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile index 3e0859c2..27be32c3 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile +++ b/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile @@ -122,9 +122,6 @@ RUN chown -R django:django ${APP_HOME} USER django RUN DATABASE_URL="" \ - {%- if cookiecutter.use_celery == "y" %} - CELERY_BROKER_URL="" \ - {%- endif %} DJANGO_SETTINGS_MODULE="config.settings.test" \ python manage.py compilemessages diff --git a/{{cookiecutter.project_slug}}/compose/production/django/celery/flower/start b/{{cookiecutter.project_slug}}/compose/production/django/celery/flower/start index f903a05a..c0b1cbe5 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/celery/flower/start +++ b/{{cookiecutter.project_slug}}/compose/production/django/celery/flower/start @@ -14,6 +14,6 @@ echo 'Starting flower' exec celery \ -A config.celery_app \ - -b "${CELERY_BROKER_URL}" \ + -b "${REDIS_URL}" \ flower \ --basic_auth="${CELERY_FLOWER_USER}:${CELERY_FLOWER_PASSWORD}" diff --git a/{{cookiecutter.project_slug}}/compose/production/django/entrypoint b/{{cookiecutter.project_slug}}/compose/production/django/entrypoint index dd07f2d2..685319ed 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/entrypoint +++ b/{{cookiecutter.project_slug}}/compose/production/django/entrypoint @@ -4,12 +4,6 @@ set -o errexit set -o pipefail set -o nounset - -{% if cookiecutter.use_celery == 'y' %} -# N.B. If only .env files supported variable expansion... -export CELERY_BROKER_URL="${REDIS_URL}" -{% endif %} - 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/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py index f1039b74..ec7c500a 100644 --- a/{{cookiecutter.project_slug}}/config/settings/base.py +++ b/{{cookiecutter.project_slug}}/config/settings/base.py @@ -289,7 +289,7 @@ if USE_TZ: # https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-timezone CELERY_TIMEZONE = TIME_ZONE # https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-broker_url -CELERY_BROKER_URL = env("CELERY_BROKER_URL") +CELERY_BROKER_URL = env("REDIS_URL") # https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-result_backend CELERY_RESULT_BACKEND = CELERY_BROKER_URL # https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-extended diff --git a/{{cookiecutter.project_slug}}/docs/conf.py b/{{cookiecutter.project_slug}}/docs/conf.py index 40d59dbb..31a828fe 100644 --- a/{{cookiecutter.project_slug}}/docs/conf.py +++ b/{{cookiecutter.project_slug}}/docs/conf.py @@ -26,9 +26,6 @@ else: sys.path.insert(0, os.path.abspath("..")) {%- endif %} os.environ["DATABASE_URL"] = "sqlite:///readthedocs.db" -{%- if cookiecutter.use_celery == 'y' %} -os.environ["CELERY_BROKER_URL"] = os.getenv("REDIS_URL", "redis://redis:6379") -{%- endif %} os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local") django.setup()