mirror of
https://github.com/immich-app/immich.git
synced 2024-12-24 10:37:28 +02:00
chore(server): redis error handling (#2212)
* chore(server): bull error handler * chore(server): redis error handling * Let's not touch bull
This commit is contained in:
parent
9fc70fc24e
commit
a68fbcc520
@ -1,13 +1,21 @@
|
||||
import { IoAdapter } from '@nestjs/platform-socket.io';
|
||||
import { createAdapter } from '@socket.io/redis-adapter';
|
||||
import Redis from 'ioredis';
|
||||
import { Logger } from '@nestjs/common';
|
||||
import { ServerOptions } from 'socket.io';
|
||||
import { redisConfig } from './infra.config';
|
||||
|
||||
export class RedisIoAdapter extends IoAdapter {
|
||||
private readonly logger = new Logger(RedisIoAdapter.name);
|
||||
createIOServer(port: number, options?: ServerOptions): any {
|
||||
const pubClient = new Redis(redisConfig);
|
||||
pubClient.on('error', (error) => {
|
||||
this.logger.error(`Redis pubClient: ${error}`);
|
||||
});
|
||||
const subClient = pubClient.duplicate();
|
||||
subClient.on('error', (error) => {
|
||||
this.logger.error(`Redis subClient: ${error}`);
|
||||
});
|
||||
const server = super.createIOServer(port, options);
|
||||
server.adapter(createAdapter(pubClient, subClient));
|
||||
return server;
|
||||
|
Loading…
Reference in New Issue
Block a user