1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-25 10:43:13 +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:
Skyler Mäntysaari 2023-04-09 04:35:08 +03:00 committed by GitHub
parent 9fc70fc24e
commit a68fbcc520
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;