use REDIS_CON for redis connection string

This commit is contained in:
Simon
2024-12-23 22:29:52 +07:00
parent f25c2025e8
commit a4435fdd60
7 changed files with 13 additions and 19 deletions

View File

@@ -37,8 +37,7 @@ class EnvironmentSettings:
CACHE_DIR: str = str(environ.get("TA_CACHE_DIR", "/cache"))
# Redis
REDIS_HOST: str = str(environ.get("REDIS_HOST"))
REDIS_PORT: int = int(environ.get("REDIS_PORT", 6379))
REDIS_CON: str = str(environ.get("REDIS_CON"))
REDIS_NAME_SPACE: str = str(environ.get("REDIS_NAME_SPACE", "ta:"))
# ElasticSearch
@@ -93,8 +92,7 @@ class EnvironmentSettings:
"""debug redis conf paths"""
print(
f"""
REDIS_HOST: {self.REDIS_HOST}
REDIS_PORT: {self.REDIS_PORT}
REDIS_CON: {self.REDIS_CON}
REDIS_NAME_SPACE: {self.REDIS_NAME_SPACE}"""
)

View File

@@ -17,10 +17,8 @@ class RedisBase:
NAME_SPACE: str = EnvironmentSettings.REDIS_NAME_SPACE
def __init__(self):
self.conn = redis.Redis(
host=EnvironmentSettings.REDIS_HOST,
port=EnvironmentSettings.REDIS_PORT,
decode_responses=True,
self.conn = redis.from_url(
url=EnvironmentSettings.REDIS_CON, decode_responses=True
)

View File

@@ -62,7 +62,9 @@ EXPECTED_ENV_VARS = [
"TA_HOST",
]
UNEXPECTED_ENV_VARS = {
"TA_UWSGI_PORT": "Has been replaced with 'TA_BACKEND_PORT'"
"TA_UWSGI_PORT": "Has been replaced with 'TA_BACKEND_PORT'",
"REDIS_HOST": "Has been replaced with 'REDIS_CON' connection string",
"REDIS_PORT": "Has been consolidated in 'REDIS_CON' connection string",
}
INST = "https://github.com/tubearchivist/tubearchivist#installing-and-updating"
NGINX = "/etc/nginx/sites-available/default"

View File

@@ -5,14 +5,11 @@ import os
from celery import Celery
from common.src.env_settings import EnvironmentSettings
REDIS_HOST = EnvironmentSettings.REDIS_HOST
REDIS_PORT = EnvironmentSettings.REDIS_PORT
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
app = Celery(
"tasks",
broker=f"redis://{REDIS_HOST}:{REDIS_PORT}",
backend=f"redis://{REDIS_HOST}:{REDIS_PORT}",
broker=EnvironmentSettings.REDIS_CON,
backend=EnvironmentSettings.REDIS_CON,
result_extended=True,
)
app.config_from_object(