mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-04 03:27:09 -05: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 { IoAdapter } from '@nestjs/platform-socket.io';
 | 
				
			||||||
import { createAdapter } from '@socket.io/redis-adapter';
 | 
					import { createAdapter } from '@socket.io/redis-adapter';
 | 
				
			||||||
import Redis from 'ioredis';
 | 
					import Redis from 'ioredis';
 | 
				
			||||||
 | 
					import { Logger } from '@nestjs/common';
 | 
				
			||||||
import { ServerOptions } from 'socket.io';
 | 
					import { ServerOptions } from 'socket.io';
 | 
				
			||||||
import { redisConfig } from './infra.config';
 | 
					import { redisConfig } from './infra.config';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class RedisIoAdapter extends IoAdapter {
 | 
					export class RedisIoAdapter extends IoAdapter {
 | 
				
			||||||
 | 
					  private readonly logger = new Logger(RedisIoAdapter.name);
 | 
				
			||||||
  createIOServer(port: number, options?: ServerOptions): any {
 | 
					  createIOServer(port: number, options?: ServerOptions): any {
 | 
				
			||||||
    const pubClient = new Redis(redisConfig);
 | 
					    const pubClient = new Redis(redisConfig);
 | 
				
			||||||
 | 
					    pubClient.on('error', (error) => {
 | 
				
			||||||
 | 
					      this.logger.error(`Redis pubClient: ${error}`);
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
    const subClient = pubClient.duplicate();
 | 
					    const subClient = pubClient.duplicate();
 | 
				
			||||||
 | 
					    subClient.on('error', (error) => {
 | 
				
			||||||
 | 
					      this.logger.error(`Redis subClient: ${error}`);
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
    const server = super.createIOServer(port, options);
 | 
					    const server = super.createIOServer(port, options);
 | 
				
			||||||
    server.adapter(createAdapter(pubClient, subClient));
 | 
					    server.adapter(createAdapter(pubClient, subClient));
 | 
				
			||||||
    return server;
 | 
					    return server;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user