From 6e1e3bc0eae4f6ed8ae3e60088e099bf5074d01f Mon Sep 17 00:00:00 2001 From: dakkar Date: Sun, 21 Jul 2024 11:02:46 +0100 Subject: [PATCH] pass redis config as-is to postgres cache also, explicitly state that `path` is a valid config option for redis (tells `ioredis` to connect via UNIX socked instead of TCP socket) --- packages/backend/src/config.ts | 5 +++-- packages/backend/src/postgres.ts | 6 +----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index 58c4d028aa..92774328cc 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -12,9 +12,10 @@ import * as Sentry from '@sentry/node'; import type { RedisOptions } from 'ioredis'; type RedisOptionsSource = Partial & { - host: string; - port: number; + host?: string; + port?: number; family?: number; + path?: string, pass: string; db?: number; prefix?: string; diff --git a/packages/backend/src/postgres.ts b/packages/backend/src/postgres.ts index 4a1b42383f..b7c418fa59 100644 --- a/packages/backend/src/postgres.ts +++ b/packages/backend/src/postgres.ts @@ -236,12 +236,8 @@ export function createPostgresDataSource(config: Config) { cache: !config.db.disableCache && process.env.NODE_ENV !== 'test' ? { // dbをcloseしても何故かredisのコネクションが内部的に残り続けるようで、テストの際に支障が出るため無効にする(キャッシュも含めてテストしたいため本当は有効にしたいが...) type: 'ioredis', options: { - host: config.redis.host, - port: config.redis.port, - family: config.redis.family ?? 0, - password: config.redis.pass, + ...config.redis, keyPrefix: `${config.redis.prefix}:query:`, - db: config.redis.db ?? 0, }, } : false, logging: log,