]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Enhancement: Allow to set a prefix for keys and channels in redis (#3993)
authoramo13 <amaury@mailbox.org>
Wed, 16 Aug 2023 00:05:01 +0000 (02:05 +0200)
committerGitHub <noreply@github.com>
Wed, 16 Aug 2023 00:05:01 +0000 (00:05 +0000)
docs/configuration.md
src/paperless/settings.py

index 0ed2218a69b80aa5f5e3fecc213122f9bab91280..c38221e50ea3d3a0cfcf186484685aae1637014d 100644 (file)
@@ -35,6 +35,12 @@ matcher.
 
     Defaults to `redis://localhost:6379`.
 
+`PAPERLESS_REDIS_PREFIX=<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=<engine_name>`
index b33d7fb7dbd33dc5b3dd2bf65f98a3030e4d1cfa..7d2dda0d93e7e55223c4d4a07cfd9211bbf4c185 100644 (file)
@@ -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)