mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Fix #29770 by only parsing REDIS_PORT and REDIS_DB variable if REDIS_URL is not used.
This commit is contained in:
parent
19f4aa1147
commit
0f522b77a2
1 changed files with 5 additions and 7 deletions
|
@ -241,20 +241,18 @@ const redisConfigFromEnv = (env) => {
|
||||||
// which means we can't use it. But this is something that should be looked into.
|
// which means we can't use it. But this is something that should be looked into.
|
||||||
const redisPrefix = env.REDIS_NAMESPACE ? `${env.REDIS_NAMESPACE}:` : '';
|
const redisPrefix = env.REDIS_NAMESPACE ? `${env.REDIS_NAMESPACE}:` : '';
|
||||||
|
|
||||||
let redisPort = parseIntFromEnv(env.REDIS_PORT, 6379, 'REDIS_PORT');
|
|
||||||
let redisDatabase = parseIntFromEnv(env.REDIS_DB, 0, 'REDIS_DB');
|
|
||||||
|
|
||||||
/** @type {import('ioredis').RedisOptions} */
|
/** @type {import('ioredis').RedisOptions} */
|
||||||
const redisParams = {
|
const redisParams = typeof env.REDIS_URL !== 'string' ? {
|
||||||
host: env.REDIS_HOST || '127.0.0.1',
|
host: env.REDIS_HOST || '127.0.0.1',
|
||||||
port: redisPort,
|
port: parseIntFromEnv(env.REDIS_PORT, 6379, 'REDIS_PORT'),
|
||||||
// Force support for both IPv6 and IPv4, by default ioredis sets this to 4,
|
// Force support for both IPv6 and IPv4, by default ioredis sets this to 4,
|
||||||
// only allowing IPv4 connections:
|
// only allowing IPv4 connections:
|
||||||
// https://github.com/redis/ioredis/issues/1576
|
// https://github.com/redis/ioredis/issues/1576
|
||||||
family: 0,
|
family: 0,
|
||||||
db: redisDatabase,
|
db: parseIntFromEnv(env.REDIS_DB, 0, 'REDIS_DB'),
|
||||||
password: env.REDIS_PASSWORD || undefined,
|
password: env.REDIS_PASSWORD || undefined,
|
||||||
};
|
} : {};
|
||||||
|
|
||||||
|
|
||||||
// redisParams.path takes precedence over host and port.
|
// redisParams.path takes precedence over host and port.
|
||||||
if (env.REDIS_URL && env.REDIS_URL.startsWith('unix://')) {
|
if (env.REDIS_URL && env.REDIS_URL.startsWith('unix://')) {
|
||||||
|
|
Loading…
Reference in a new issue