Skip to main content
Glama
redis.ts1.4 kB
// src/support/redis.ts import { Redis } from 'ioredis'; const url = process.env.REDIS_URL || 'redis://127.0.0.1:6379'; export const redis = new Redis(url, { // ⚠️ augmente (ou neutralise) la limite par requête pendant le boot maxRetriesPerRequest: 3, // ou un nombre plus grand, ex. 20 enableReadyCheck: true, // meilleure stratégie de reconnexion retryStrategy(times) { const delay = Math.min(1000 * Math.pow(2, times), 15000); return delay; // ms (retente indéfiniment) }, connectTimeout: 10000, lazyConnect: true, // on appelle .connect() explicitement }); function errMsg(e: unknown) { if (!e) return '(unknown)'; if (typeof e === 'string') return e; const any = e as any; return any?.message || JSON.stringify(any); } redis.on('connect', () => process.stderr.write('[redis] connect\n')); redis.on('ready', () => process.stderr.write('[redis] ready\n')); redis.on('error', (e: unknown) => { const msg = e && typeof e === 'object' && 'message' in (e as any) ? (e as any).message : String(e); process.stderr.write(`[redis][error] ${msg}\n`); }); export async function connectRedis() { try { await redis.connect(); process.stderr.write('[redis] connected (await)\n'); } catch (e) { process.stderr.write(`[redis][fatal] connect failed: ${errMsg(e)}\n`); throw e; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/paracetamol951/caisse-enregistreuse-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server