From a0005c8b3e5275b119017700ef5de208bcb819cd Mon Sep 17 00:00:00 2001 From: amo13 Date: Wed, 16 Aug 2023 02:05:01 +0200 Subject: [PATCH] Enhancement: Allow to set a prefix for keys and channels in redis (#3993) --- docs/configuration.md | 6 ++++++ src/paperless/settings.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/docs/configuration.md b/docs/configuration.md index 0ed2218a6..c38221e50 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -35,6 +35,12 @@ matcher. Defaults to `redis://localhost:6379`. +`PAPERLESS_REDIS_PREFIX=` + +: Prefix to be used in Redis for keys and channels. Useful for sharing one Redis server among multiple Paperless instances. + + Defaults to no prefix. + ### Database `PAPERLESS_DBENGINE=` diff --git a/src/paperless/settings.py b/src/paperless/settings.py index b33d7fb7d..7d2dda0d9 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -364,6 +364,7 @@ CHANNEL_LAYERS = { "hosts": [_CHANNELS_REDIS_URL], "capacity": 2000, # default 100 "expiry": 15, # default 60 + "prefix": os.getenv("PAPERLESS_REDIS_PREFIX", ""), }, }, } @@ -679,6 +680,9 @@ CELERY_TASK_SEND_SENT_EVENT = True CELERY_SEND_TASK_SENT_EVENT = True CELERY_BROKER_CONNECTION_RETRY = True CELERY_BROKER_CONNECTION_RETRY_ON_STARTUP = True +CELERY_BROKER_TRANSPORT_OPTIONS = { + "global_keyprefix": os.getenv("PAPERLESS_REDIS_PREFIX", ""), +} CELERY_TASK_TRACK_STARTED = True CELERY_TASK_TIME_LIMIT: Final[int] = __get_int("PAPERLESS_WORKER_TIMEOUT", 1800)