Skip to content

Commit 1a4f703

Browse files
authored
Refine the available settings for RQ_QUEUES #103 (#208)
Signed-off-by: tdruez <[email protected]>
1 parent 6b4c819 commit 1a4f703

File tree

3 files changed

+50
-11
lines changed

3 files changed

+50
-11
lines changed

dejacode/settings.py

+20-9
Original file line numberDiff line numberDiff line change
@@ -411,26 +411,31 @@ def gettext_noop(s):
411411
"django.core.files.uploadhandler.TemporaryFileUploadHandler",
412412
]
413413

414-
REDIS_URL = env.str("REDIS_URL", default="redis://127.0.0.1:6379")
415-
416414
# Default setup for the cache
417415
# See https://docs.djangoproject.com/en/dev/topics/cache/
418416
CACHE_BACKEND = env.str("CACHE_BACKEND", default="django.core.cache.backends.locmem.LocMemCache")
417+
# Set CACHE_REDIS_URL to the URL pointing to your Redis instance available for caching,
418+
# using the appropriate scheme.
419+
# For example: "redis://[[username]:[password]]@localhost:6379/0"
420+
# See the redis-py docs for details on the available schemes at
421+
# https://redis-py.readthedocs.io/en/stable/connections.html#redis.connection.ConnectionPool.from_url
422+
CACHE_REDIS_URL = env.str("CACHE_REDIS_URL", default="redis://127.0.0.1:6379")
423+
419424
CACHES = {
420425
"default": {
421426
"BACKEND": CACHE_BACKEND,
422-
"LOCATION": REDIS_URL,
427+
"LOCATION": CACHE_REDIS_URL,
423428
"TIMEOUT": 900, # 15 minutes, in seconds
424429
},
425430
"licensing": {
426431
"BACKEND": CACHE_BACKEND,
427-
"LOCATION": REDIS_URL,
432+
"LOCATION": CACHE_REDIS_URL,
428433
"TIMEOUT": 300, # 10 minutes, in seconds
429434
"KEY_PREFIX": "licensing",
430435
},
431436
"vulnerabilities": {
432437
"BACKEND": CACHE_BACKEND,
433-
"LOCATION": REDIS_URL,
438+
"LOCATION": CACHE_REDIS_URL,
434439
"TIMEOUT": 3600, # 1 hour, in seconds
435440
"KEY_PREFIX": "vuln",
436441
},
@@ -439,10 +444,16 @@ def gettext_noop(s):
439444
# Job Queue
440445
RQ_QUEUES = {
441446
"default": {
442-
"HOST": env.str("DEJACODE_REDIS_HOST", default="localhost"),
443-
"PORT": env.str("DEJACODE_REDIS_PORT", default="6379"),
444-
"PASSWORD": env.str("DEJACODE_REDIS_PASSWORD", default=""),
445-
"DEFAULT_TIMEOUT": env.int("DEJACODE_RQ_DEFAULT_TIMEOUT", default=360),
447+
"HOST": env.str("DEJACODE_RQ_REDIS_HOST", default="localhost"),
448+
"PORT": env.str("DEJACODE_RQ_REDIS_PORT", default="6379"),
449+
"DB": env.int("DEJACODE_RQ_REDIS_DB", default=0),
450+
"USERNAME": env.str("DEJACODE_RQ_REDIS_USERNAME", default=None),
451+
"PASSWORD": env.str("DEJACODE_RQ_REDIS_PASSWORD", default=""),
452+
"DEFAULT_TIMEOUT": env.int("DEJACODE_RQ_REDIS_DEFAULT_TIMEOUT", default=360),
453+
# Enable SSL for Redis connections when deploying DejaCode in environments where
454+
# Redis is hosted on a separate system (e.g., cloud deployment or remote
455+
# Redis server) to secure data in transit.
456+
"SSL": env.bool("DEJACODE_RQ_REDIS_SSL", default=False),
446457
},
447458
}
448459

docker.env

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ DATABASE_NAME=dejacode_db
88
DATABASE_USER=dejacode
99
DATABASE_PASSWORD=dejacode
1010

11-
DEJACODE_REDIS_HOST=redis
11+
DEJACODE_RQ_REDIS_HOST=redis
1212
DEJACODE_ASYNC=True
1313

1414
STATIC_ROOT=/var/dejacode/static/
1515
MEDIA_ROOT=/var/dejacode/media/
16-
REDIS_URL=redis://redis:6379
16+
1717
CACHE_BACKEND=django.core.cache.backends.redis.RedisCache
18+
CACHE_REDIS_URL=redis://redis:6379
19+
1820
CLAMD_ENABLED=True
1921
CLAMD_TCP_ADDR=clamav

docs/application-settings.rst

+26
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,32 @@ default the ``US/Pacific`` time zone is used::
205205
You can view a detailed list of time zones `here.
206206
<https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>`_
207207

208+
.. _dejacode_settings_job_queue_and_workers:
209+
210+
Job Queue and Workers
211+
=====================
212+
213+
DejaCode leverages the RQ (Redis Queue) Python library for job queuing and background
214+
processing with workers.
215+
216+
By default, it is configured to use the "redis" service in the Docker Compose stack.
217+
218+
For deployments where Redis is hosted on a separate system
219+
(e.g., a cloud-based deployment or a remote Redis server),
220+
the Redis instance used by RQ can be customized using the following settings::
221+
222+
DEJACODE_RQ_REDIS_HOST=localhost
223+
DEJACODE_RQ_REDIS_PORT=6379
224+
DEJACODE_RQ_REDIS_DB=0
225+
DEJACODE_RQ_REDIS_USERNAME=<username>
226+
DEJACODE_RQ_REDIS_PASSWORD=<password>
227+
DEJACODE_RQ_REDIS_DEFAULT_TIMEOUT=360
228+
229+
To enhance security, it is recommended to enable SSL for Redis connections.
230+
SSL is disabled by default but can be enabled with the following configuration::
231+
232+
DEJACODE_RQ_REDIS_SSL=True
233+
208234
.. _dejacode_settings_aboutcode_integrations:
209235

210236
AboutCode integrations

0 commit comments

Comments
 (0)