diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index e7745f0..93ba2bb 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -90,7 +90,6 @@ jobs: deploy: name: Deploy production (on server) - needs: [ci] if: github.ref == 'refs/heads/main' && github.event_name == 'push' runs-on: docker-host steps: @@ -175,6 +174,7 @@ jobs: upsert CUSTOM_OPENAI_API_KEY "$CUSTOM_OPENAI_API_KEY" upsert OPENAI_API_KEY "$OPENAI_API_KEY" upsert OLLAMA_BASE_URL "$OLLAMA_BASE_URL" + upsert REDIS_HOST "redis" upsert EMAIL_PROVIDER "$EMAIL_PROVIDER" upsert SMTP_FROM "$SMTP_FROM" upsert RESEND_API_KEY "$RESEND_API_KEY" diff --git a/memento-note/lib/redis.ts b/memento-note/lib/redis.ts index dc19070..5a79c6c 100644 --- a/memento-note/lib/redis.ts +++ b/memento-note/lib/redis.ts @@ -4,20 +4,32 @@ const globalForRedis = globalThis as unknown as { redis?: Redis }; const redis = globalForRedis.redis ?? - new Redis({ - host: process.env.REDIS_HOST ?? 'localhost', - port: parseInt(process.env.REDIS_PORT ?? '6379'), - password: process.env.REDIS_PASSWORD, - lazyConnect: true, - retryStrategy(times) { - if (times > 10) { - console.error('[redis] Max retries exceeded, will retry in 30s'); - return 30000; - } - return Math.min(times * 200, 2000); - }, - maxRetriesPerRequest: 3, - }); + (process.env.REDIS_URL + ? new Redis(process.env.REDIS_URL, { + lazyConnect: true, + retryStrategy(times) { + if (times > 10) { + console.error('[redis] Max retries exceeded, will retry in 30s'); + return 30000; + } + return Math.min(times * 200, 2000); + }, + maxRetriesPerRequest: 3, + }) + : new Redis({ + host: process.env.REDIS_HOST ?? 'localhost', + port: parseInt(process.env.REDIS_PORT ?? '6379'), + password: process.env.REDIS_PASSWORD, + lazyConnect: true, + retryStrategy(times) { + if (times > 10) { + console.error('[redis] Max retries exceeded, will retry in 30s'); + return 30000; + } + return Math.min(times * 200, 2000); + }, + maxRetriesPerRequest: 3, + })); redis.on('error', (err) => { console.error('[redis] Connection error:', err.message);