|
@@ -3,13 +3,27 @@ import { BullModuleOptions } from '@nestjs/bull';
|
|
|
import { RedisOptions } from 'ioredis';
|
|
|
import { ConfigurationOptions } from 'typesense/lib/Typesense/Configuration';
|
|
|
|
|
|
-export const redisConfig: RedisOptions = {
|
|
|
- host: process.env.REDIS_HOSTNAME || 'immich_redis',
|
|
|
- port: parseInt(process.env.REDIS_PORT || '6379'),
|
|
|
- db: parseInt(process.env.REDIS_DBINDEX || '0'),
|
|
|
- password: process.env.REDIS_PASSWORD || undefined,
|
|
|
- path: process.env.REDIS_SOCKET || undefined,
|
|
|
-};
|
|
|
+function parseRedisConfig(): RedisOptions {
|
|
|
+ const redisUrl = process.env.REDIS_URL;
|
|
|
+ if (redisUrl && redisUrl.startsWith('ioredis://')) {
|
|
|
+ try {
|
|
|
+ const decodedString = Buffer.from(redisUrl.slice(10), 'base64').toString();
|
|
|
+ return JSON.parse(decodedString);
|
|
|
+ } catch (error) {
|
|
|
+ throw new Error(`Failed to decode redis options: ${error}`);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ host: process.env.REDIS_HOSTNAME || 'immich_redis',
|
|
|
+ port: parseInt(process.env.REDIS_PORT || '6379'),
|
|
|
+ db: parseInt(process.env.REDIS_DBINDEX || '0'),
|
|
|
+ username: process.env.REDIS_USERNAME || undefined,
|
|
|
+ password: process.env.REDIS_PASSWORD || undefined,
|
|
|
+ path: process.env.REDIS_SOCKET || undefined,
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+export const redisConfig: RedisOptions = parseRedisConfig();
|
|
|
|
|
|
export const bullConfig: BullModuleOptions = {
|
|
|
prefix: 'immich_bull',
|