fix: enhance Redis connection handling and improve error logging in API startup

This commit is contained in:
Rotimi Best
2026-03-11 12:57:44 +01:00
parent ff1d4a2749
commit cd470b5d05
5 changed files with 34 additions and 12 deletions
+9 -1
View File
@@ -23,9 +23,17 @@ client.on('reconnecting', () => {
let isConnected = false;
export async function connectRedis(): Promise<void> {
if (!isConnected) {
if (!env.REDIS_URL) {
console.warn('REDIS_URL not set, Redis features disabled');
return;
}
if (isConnected) return;
try {
await client.connect();
isConnected = true;
} catch (error) {
console.error('Redis connection failed, API will run without Redis:', error);
// Don't throw - allow API to start; rate limiting and caching will degrade gracefully
}
}