Skip to content

Commit f8bb0d1

Browse files
mangod12claude
andcommitted
fix: make Redis non-fatal in production to prevent crash loop on Cloud Run
Redis init was raising RuntimeError in production, causing Gunicorn worker crash loop when Memorystore connection fails during cold start. Now logs error but continues — app runs in degraded mode without Redis (no cache, no pub/sub, dashboard uses DB fallback). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 437d37e commit f8bb0d1

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

backend/app/core/redis_client.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,10 @@ async def init_redis():
2323
_redis_client = client
2424
logger.info("Connected to Redis at %s", settings.REDIS_URL)
2525
except Exception as exc:
26-
if settings.APP_ENV.lower() == "production":
27-
logger.error("Redis connection failed in production: %s", exc)
28-
raise RuntimeError(
29-
f"Redis is required in production but unavailable: {exc}"
30-
) from exc
26+
logger.error("Redis connection failed: %s", exc)
3127

32-
logger.warning("Redis not available — trying fakeredis for local dev")
28+
if settings.APP_ENV.lower() != "production":
29+
logger.warning("Trying fakeredis for local dev")
3330
try:
3431
import fakeredis.aioredis as fakeredis_mod
3532

0 commit comments

Comments
 (0)