mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
chore(server): use ioredis (#2116)
This commit is contained in:
parent
009b6e3ca5
commit
49f66be8af
8 changed files with 74 additions and 64 deletions
|
|
@ -1,3 +1,4 @@
|
|||
export * from './database.config';
|
||||
export * from './infra.config';
|
||||
export * from './infra.module';
|
||||
export * from './redis-io.adapter';
|
||||
|
|
|
|||
|
|
@ -1,16 +1,19 @@
|
|||
import { QueueName } from '@app/domain';
|
||||
import { BullModuleOptions } from '@nestjs/bull';
|
||||
import { RedisOptions } from 'ioredis';
|
||||
import { ConfigurationOptions } from 'typesense/lib/Typesense/Configuration';
|
||||
import { QueueName } from '../../domain/src';
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
export const bullConfig: BullModuleOptions = {
|
||||
prefix: 'immich_bull',
|
||||
redis: {
|
||||
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,
|
||||
},
|
||||
redis: redisConfig,
|
||||
defaultJobOptions: {
|
||||
attempts: 3,
|
||||
removeOnComplete: true,
|
||||
|
|
|
|||
15
server/libs/infra/src/redis-io.adapter.ts
Normal file
15
server/libs/infra/src/redis-io.adapter.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { IoAdapter } from '@nestjs/platform-socket.io';
|
||||
import { createAdapter } from '@socket.io/redis-adapter';
|
||||
import Redis from 'ioredis';
|
||||
import { ServerOptions } from 'socket.io';
|
||||
import { redisConfig } from './infra.config';
|
||||
|
||||
export class RedisIoAdapter extends IoAdapter {
|
||||
createIOServer(port: number, options?: ServerOptions): any {
|
||||
const pubClient = new Redis(redisConfig);
|
||||
const subClient = pubClient.duplicate();
|
||||
const server = super.createIOServer(port, options);
|
||||
server.adapter(createAdapter(pubClient, subClient));
|
||||
return server;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue