fix(redis): Timeouts für Async-Pool + Start-Health-Check-Log
get_async_redis() hatte keine socket_connect_timeout/socket_timeout/ max_connections – ein gehängtes Redis hätte Requests unbegrenzt blockiert statt schnell zu failen. Zusätzlich einmaliger Ping im Lifespan-Startup, nur zur Log-Sichtbarkeit (blockiert Boot nicht). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Ahyx6D3r7G1EuAc42nezn
This commit is contained in:
@@ -52,6 +52,17 @@ async def lifespan(app: FastAPI):
|
||||
from app.services.scheduler_service import start as start_scheduler
|
||||
start_scheduler()
|
||||
|
||||
# Async-Redis-Pool: einmaliger Ping beim Start, nur zur Sichtbarkeit im Log
|
||||
# (Sessions/Lockouts/Nonce-Cache brauchen Redis, App startet aber auch ohne –
|
||||
# Fehler zeigen sich dann erst beim ersten Request, siehe get_async_redis()).
|
||||
if "pytest" not in sys.modules:
|
||||
from app.core.redis import get_async_redis
|
||||
try:
|
||||
await get_async_redis().ping()
|
||||
_log.info("Async-Redis-Pool: Verbindung beim Start OK.")
|
||||
except Exception as exc:
|
||||
_log.warning("Async-Redis-Pool: kein Redis beim Start erreichbar (%s).", exc)
|
||||
|
||||
yield
|
||||
# Shutdown
|
||||
from app.services.scheduler_service import shutdown as shutdown_scheduler
|
||||
|
||||
Reference in New Issue
Block a user