mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 04:05:39 -04:00
* Add ability to pass redis hostname as env var * Read postgres host from env var in microservices * Update .env.example with postgres and redis hostname vars
25 lines
774 B
TypeScript
25 lines
774 B
TypeScript
import { IoAdapter } from '@nestjs/platform-socket.io';
|
|
import { RedisClient } from 'redis';
|
|
import { ServerOptions } from 'socket.io';
|
|
import { createAdapter } from 'socket.io-redis';
|
|
|
|
const redis_host = process.env.REDIS_HOSTNAME || 'immich_redis'
|
|
// const pubClient = createClient({ url: `redis://${redis_host}:6379` });
|
|
// const subClient = pubClient.duplicate();
|
|
|
|
const pubClient = new RedisClient({
|
|
host: redis_host,
|
|
port: 6379,
|
|
});
|
|
|
|
const subClient = pubClient.duplicate();
|
|
const redisAdapter = createAdapter({ pubClient, subClient });
|
|
|
|
export class RedisIoAdapter extends IoAdapter {
|
|
createIOServer(port: number, options?: ServerOptions): any {
|
|
const server = super.createIOServer(port, options);
|
|
server.adapter(redisAdapter);
|
|
return server;
|
|
}
|
|
}
|