Skip to content

Commit a00816d

Browse files
Fix: read Redis host/port from REDIS_HOST/REDIS_PORT env vars instead of hardcoded localhost
1 parent e15ec94 commit a00816d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

core/settings/project.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
"utils",
2323
]
2424

25-
dramatiq.set_broker(RedisBroker(host="localhost", port=6379))
25+
_REDIS_HOST = os.getenv("REDIS_HOST", "localhost")
26+
_REDIS_PORT = int(os.getenv("REDIS_PORT", "6379"))
27+
dramatiq.set_broker(RedisBroker(host=_REDIS_HOST, port=_REDIS_PORT))
2628

2729
DATABASES = {}
2830

tasks/task_runners.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@
6767
(c) OpenStreetMap contributors.
6868
This file is made available under the Open Database License: http://opendatacommons.org/licenses/odbl/1.0/. Any rights in individual contents of the database are licensed under the Database Contents License: http://opendatacommons.org/licenses/dbcl/1.0/
6969
"""
70-
redis_client = redis.Redis.from_url("redis://localhost:6379/0")
70+
_redis_host = os.getenv("REDIS_HOST", "localhost")
71+
_redis_port = int(os.getenv("REDIS_PORT", "6379"))
72+
redis_client = redis.Redis(host=_redis_host, port=_redis_port, db=0)
7173
abortable = Abortable(backend=backends.RedisBackend(client=redis_client))
7274
dramatiq.get_broker().add_middleware(abortable)
7375

0 commit comments

Comments
 (0)