Fix startup issues
This commit is contained in:
@@ -7,7 +7,7 @@ Provides common settings and patterns
|
||||
import os
|
||||
from typing import List, Dict, Optional, Any
|
||||
from pydantic_settings import BaseSettings
|
||||
from pydantic import validator
|
||||
from pydantic import validator, Field
|
||||
|
||||
|
||||
class BaseServiceSettings(BaseSettings):
|
||||
@@ -54,8 +54,32 @@ class BaseServiceSettings(BaseSettings):
|
||||
# ================================================================
|
||||
# REDIS CONFIGURATION
|
||||
# ================================================================
|
||||
|
||||
REDIS_URL: str = os.getenv("REDIS_URL", "redis://redis-service:6379")
|
||||
|
||||
@property
|
||||
def REDIS_URL(self) -> str:
|
||||
"""Build Redis URL from secure components"""
|
||||
# Try complete URL first (for backward compatibility)
|
||||
complete_url = os.getenv("REDIS_URL")
|
||||
if complete_url:
|
||||
return complete_url
|
||||
|
||||
# Build from components (secure approach)
|
||||
password = os.getenv("REDIS_PASSWORD", "")
|
||||
host = os.getenv("REDIS_HOST", "redis-service")
|
||||
port = os.getenv("REDIS_PORT", "6379")
|
||||
|
||||
# DEBUG: print what we're using
|
||||
import sys
|
||||
print(f"[DEBUG REDIS_URL] password={repr(password)}, host={host}, port={port}", file=sys.stderr)
|
||||
|
||||
if password:
|
||||
url = f"redis://:{password}@{host}:{port}"
|
||||
print(f"[DEBUG REDIS_URL] Returning URL with auth: {url}", file=sys.stderr)
|
||||
return url
|
||||
url = f"redis://{host}:{port}"
|
||||
print(f"[DEBUG REDIS_URL] Returning URL without auth: {url}", file=sys.stderr)
|
||||
return url
|
||||
|
||||
REDIS_DB: int = int(os.getenv("REDIS_DB", "0"))
|
||||
REDIS_MAX_CONNECTIONS: int = int(os.getenv("REDIS_MAX_CONNECTIONS", "50"))
|
||||
REDIS_RETRY_ON_TIMEOUT: bool = True
|
||||
@@ -65,7 +89,7 @@ class BaseServiceSettings(BaseSettings):
|
||||
"TCP_KEEPINTVL": 3,
|
||||
"TCP_KEEPCNT": 5,
|
||||
}
|
||||
|
||||
|
||||
@property
|
||||
def REDIS_URL_WITH_DB(self) -> str:
|
||||
"""Get Redis URL with database number"""
|
||||
|
||||
Reference in New Issue
Block a user