From 3638e1884448403e0f8db915b6ef0c3d3b0688ac Mon Sep 17 00:00:00 2001 From: Jade Meskill Date: Wed, 12 Jan 2022 19:44:11 -0700 Subject: [PATCH] add support for different redis db --- bookwyrm/management/commands/erase_streams.py | 2 +- bookwyrm/redis_store.py | 2 +- bookwyrm/settings.py | 3 ++- celerywyrm/settings.py | 5 +++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bookwyrm/management/commands/erase_streams.py b/bookwyrm/management/commands/erase_streams.py index 1d34b1bb6..cb732079d 100644 --- a/bookwyrm/management/commands/erase_streams.py +++ b/bookwyrm/management/commands/erase_streams.py @@ -5,7 +5,7 @@ import redis from bookwyrm import settings r = redis.Redis( - host=settings.REDIS_ACTIVITY_HOST, port=settings.REDIS_ACTIVITY_PORT, db=0 + host=settings.REDIS_ACTIVITY_HOST, port=settings.REDIS_ACTIVITY_PORT, db=settings.REDIS_ACTIVITY_DB ) diff --git a/bookwyrm/redis_store.py b/bookwyrm/redis_store.py index 964409e89..560527c92 100644 --- a/bookwyrm/redis_store.py +++ b/bookwyrm/redis_store.py @@ -8,7 +8,7 @@ r = redis.Redis( host=settings.REDIS_ACTIVITY_HOST, port=settings.REDIS_ACTIVITY_PORT, password=settings.REDIS_ACTIVITY_PASSWORD, - db=0, + db=settings.REDIS_ACTIVITY_DB, ) diff --git a/bookwyrm/settings.py b/bookwyrm/settings.py index 92ff7ecdd..22717f783 100644 --- a/bookwyrm/settings.py +++ b/bookwyrm/settings.py @@ -113,6 +113,7 @@ WSGI_APPLICATION = "bookwyrm.wsgi.application" REDIS_ACTIVITY_HOST = env("REDIS_ACTIVITY_HOST", "localhost") REDIS_ACTIVITY_PORT = env("REDIS_ACTIVITY_PORT", 6379) REDIS_ACTIVITY_PASSWORD = env("REDIS_ACTIVITY_PASSWORD", None) +REDIS_ACTIVITY_DB = env("REDIS_ACTIVITY_DB", 0) MAX_STREAM_LENGTH = int(env("MAX_STREAM_LENGTH", 200)) @@ -139,7 +140,7 @@ else: CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", - "LOCATION": f"redis://:{REDIS_ACTIVITY_PASSWORD}@{REDIS_ACTIVITY_HOST}:{REDIS_ACTIVITY_PORT}/0", + "LOCATION": f"redis://:{REDIS_ACTIVITY_PASSWORD}@{REDIS_ACTIVITY_HOST}:{REDIS_ACTIVITY_PORT}/{REDIS_ACTIVITY_DB}", "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", }, diff --git a/celerywyrm/settings.py b/celerywyrm/settings.py index 24729345b..7016d4aa1 100644 --- a/celerywyrm/settings.py +++ b/celerywyrm/settings.py @@ -6,12 +6,13 @@ from bookwyrm.settings import * REDIS_BROKER_PASSWORD = requests.utils.quote(env("REDIS_BROKER_PASSWORD", None)) REDIS_BROKER_HOST = env("REDIS_BROKER_HOST", "redis_broker") REDIS_BROKER_PORT = env("REDIS_BROKER_PORT", 6379) +REDIS_BROKER_DB = env("REDIS_BROKER_DB", 0) CELERY_BROKER_URL = ( - f"redis://:{REDIS_BROKER_PASSWORD}@{REDIS_BROKER_HOST}:{REDIS_BROKER_PORT}/0" + f"redis://:{REDIS_BROKER_PASSWORD}@{REDIS_BROKER_HOST}:{REDIS_BROKER_PORT}/{REDIS_BROKER_DB}" ) CELERY_RESULT_BACKEND = ( - f"redis://:{REDIS_BROKER_PASSWORD}@{REDIS_BROKER_HOST}:{REDIS_BROKER_PORT}/0" + f"redis://:{REDIS_BROKER_PASSWORD}@{REDIS_BROKER_HOST}:{REDIS_BROKER_PORT}/{REDIS_BROKER_DB}" ) CELERY_DEFAULT_QUEUE = "low_priority"