Refactor Celery settings to use dynamic Redis host configuration

This commit is contained in:
Ross
2026-06-17 22:17:23 +01:00
parent 56cd257474
commit 24d9594446
3 changed files with 10 additions and 7 deletions
+3 -2
View File
@@ -89,8 +89,9 @@ CIMAR_PASSWORD = "<REPLACE-WITH-SECRET>"
# Celery settings — when running in docker the redis service is # Celery settings — when running in docker the redis service is
# reachable at the `redis` hostname provided by docker compose. # reachable at the `redis` hostname provided by docker compose.
CELERY_BROKER_URL = "redis://redis:6379" REDIS_HOST = os.environ.get("REDIS_HOST", "redis")
CELERY_RESULT_BACKEND = "redis://redis:6379" CELERY_BROKER_URL = f"redis://{REDIS_HOST}:6379"
CELERY_RESULT_BACKEND = f"redis://{REDIS_HOST}:6379"
DATABASES = { DATABASES = {
"default": { "default": {
+3 -2
View File
@@ -56,5 +56,6 @@ CIMAR_PASSWORD = "<REPLACE-WITH-SECRET>"
# Celery settings — when running in docker the redis service is # Celery settings — when running in docker the redis service is
# reachable at the `redis` hostname provided by docker compose. # reachable at the `redis` hostname provided by docker compose.
CELERY_BROKER_URL = "redis://redis:6379" REDIS_HOST = os.environ.get("REDIS_HOST", "redis")
CELERY_RESULT_BACKEND = "redis://redis:6379" CELERY_BROKER_URL = f"redis://{REDIS_HOST}:6379"
CELERY_RESULT_BACKEND = f"redis://{REDIS_HOST}:6379"
+4 -3
View File
@@ -381,8 +381,9 @@ CIMAR_USERNAME = ""
CIMAR_PASSWORD = "" CIMAR_PASSWORD = ""
# Celery settings # Celery settings
CELERY_BROKER_URL = "redis://redis:6379" REDIS_HOST = os.environ.get("REDIS_HOST", "redis")
CELERY_RESULT_BACKEND = "redis://redis:6379" CELERY_BROKER_URL = f"redis://{REDIS_HOST}:6379"
CELERY_RESULT_BACKEND = f"redis://{REDIS_HOST}:6379"
# Django 6 task framework settings. # Django 6 task framework settings.
# Use DJANGO_TASK_BACKEND to select your backend implementation. # Use DJANGO_TASK_BACKEND to select your backend implementation.
@@ -403,7 +404,7 @@ CHANNEL_LAYERS = {
"default": { "default": {
"BACKEND": "channels_redis.core.RedisChannelLayer", "BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": { "CONFIG": {
"hosts": [("redis", 6379)], "hosts": [(REDIS_HOST, 6379)],
}, },
}, },
} }