Allow for Configurable Redis Port (#1124)

* root: make redis port configurable

* root: parse redis port from config as an integer

* code formatting

* lifecycle: truncate line under 100 chars

* lifecycle: incorrect indenting on newline
This commit is contained in:
Starz0r 2021-07-12 04:01:41 -05:00 committed by GitHub
parent a62e3557ac
commit 5cfbb0993a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 8 deletions

View file

@ -13,6 +13,7 @@ web:
redis: redis:
host: localhost host: localhost
port: 6379
password: '' password: ''
cache_db: 0 cache_db: 0
message_queue_db: 1 message_queue_db: 1

View file

@ -192,8 +192,8 @@ CACHES = {
"default": { "default": {
"BACKEND": "django_redis.cache.RedisCache", "BACKEND": "django_redis.cache.RedisCache",
"LOCATION": ( "LOCATION": (
f"redis://:{CONFIG.y('redis.password')}@{CONFIG.y('redis.host')}:6379" f"redis://:{CONFIG.y('redis.password')}@{CONFIG.y('redis.host')}:"
f"/{CONFIG.y('redis.cache_db')}" f"{int(CONFIG.y('redis.port'))}/{CONFIG.y('redis.cache_db')}"
), ),
"TIMEOUT": int(CONFIG.y("redis.cache_timeout", 300)), "TIMEOUT": int(CONFIG.y("redis.cache_timeout", 300)),
"OPTIONS": {"CLIENT_CLASS": "django_redis.client.DefaultClient"}, "OPTIONS": {"CLIENT_CLASS": "django_redis.client.DefaultClient"},
@ -252,8 +252,8 @@ CHANNEL_LAYERS = {
"BACKEND": "channels_redis.core.RedisChannelLayer", "BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": { "CONFIG": {
"hosts": [ "hosts": [
f"redis://:{CONFIG.y('redis.password')}@{CONFIG.y('redis.host')}:6379" f"redis://:{CONFIG.y('redis.password')}@{CONFIG.y('redis.host')}:"
f"/{CONFIG.y('redis.ws_db')}" f"{int(CONFIG.y('redis.port'))}/{CONFIG.y('redis.ws_db')}"
], ],
}, },
}, },
@ -332,11 +332,11 @@ CELERY_TASK_CREATE_MISSING_QUEUES = True
CELERY_TASK_DEFAULT_QUEUE = "authentik" CELERY_TASK_DEFAULT_QUEUE = "authentik"
CELERY_BROKER_URL = ( CELERY_BROKER_URL = (
f"redis://:{CONFIG.y('redis.password')}@{CONFIG.y('redis.host')}" f"redis://:{CONFIG.y('redis.password')}@{CONFIG.y('redis.host')}"
f":6379/{CONFIG.y('redis.message_queue_db')}" f":{int(CONFIG.y('redis.port'))}/{CONFIG.y('redis.message_queue_db')}"
) )
CELERY_RESULT_BACKEND = ( CELERY_RESULT_BACKEND = (
f"redis://:{CONFIG.y('redis.password')}@{CONFIG.y('redis.host')}" f"redis://:{CONFIG.y('redis.password')}@{CONFIG.y('redis.host')}"
f":6379/{CONFIG.y('redis.message_queue_db')}" f":{int(CONFIG.y('redis.port'))}/{CONFIG.y('redis.message_queue_db')}"
) )
# Database backup # Database backup

View file

@ -43,8 +43,8 @@ while True:
while True: while True:
try: try:
redis = Redis.from_url( redis = Redis.from_url(
f"redis://:{CONFIG.y('redis.password')}@{CONFIG.y('redis.host')}:6379" f"redis://:{CONFIG.y('redis.password')}@{CONFIG.y('redis.host')}:"
f"/{CONFIG.y('redis.ws_db')}" f"{int(CONFIG.y('redis.port'))}/{CONFIG.y('redis.ws_db')}"
) )
redis.ping() redis.ping()
break break