diff --git a/src/health/redis.healthIndicator.ts b/src/health/redis.healthIndicator.ts index 6c6f2b0ffd5d9d8e457d20ef0e378457db917f3b..bdf6308c44a4b7d2bef9e482c6615ce3b2c1640b 100644 --- a/src/health/redis.healthIndicator.ts +++ b/src/health/redis.healthIndicator.ts @@ -7,7 +7,12 @@ export class RedisHealthIndicator extends HealthIndicator { async checkRedisConnection(redisConf: { sentinelHost: string, sentinelPort: number, groupName: string; }): Promise<HealthIndicatorResult> { - const client = new IORedis({ host: redisConf.sentinelHost, port: redisConf.sentinelPort}); + const client = new IORedis({ + sentinels: [ + { host: redisConf.sentinelHost, port: redisConf.sentinelPort }, + ], + name: redisConf.groupName, + }); await new Promise((resolve, reject) => { client.on('ready', resolve); @@ -28,4 +33,4 @@ export class RedisHealthIndicator extends HealthIndicator { return this.getStatus('Redis', true); } -} +} \ No newline at end of file diff --git a/src/helpers/redis.helper.ts b/src/helpers/redis.helper.ts index 67518e890f341a08b12594fe2db3a090fe3bcb38..e73e6effe2d31689b3b4101b0730ac610406b2aa 100644 --- a/src/helpers/redis.helper.ts +++ b/src/helpers/redis.helper.ts @@ -13,7 +13,16 @@ export class Redis { Logger.log(`Entering function`, `Redis.connect`); let cfg:any={ host: this.redisConfig.sentinelHost, port: this.redisConfig.sentinelPort , + name: this.redisConfig.groupName, }; + if(this.redisConfig.sentinel){ + cfg={ + sentinels: [ + { host: this.redisConfig.sentinelHost, port: this.redisConfig.sentinelPort }, + ], + name: this.redisConfig.groupName, + }; + } const client = new IORedis(cfg); @@ -94,4 +103,4 @@ export class Redis { handleError(error, new InternalServerErrorException('Couldn\'t remove key/value in redis.')); } } -} +} \ No newline at end of file