fix: 修复 Redis 健康检查连接时序
This commit is contained in:
@@ -29,9 +29,13 @@ export class RedisClient implements OnModuleDestroy {
|
||||
}
|
||||
|
||||
try {
|
||||
const pong = String(
|
||||
await this.withTimeout(this.getClient(redisUrl).ping()),
|
||||
);
|
||||
const client = this.getClient(redisUrl);
|
||||
|
||||
if (client.status === 'wait' || client.status === 'end') {
|
||||
await this.withTimeout(client.connect());
|
||||
}
|
||||
|
||||
const pong = String(await this.withTimeout(client.ping()));
|
||||
|
||||
return pong === 'PONG'
|
||||
? { status: 'ok' }
|
||||
@@ -62,7 +66,7 @@ export class RedisClient implements OnModuleDestroy {
|
||||
this.client = new Redis(redisUrl, {
|
||||
connectTimeout: redisPingTimeoutMs,
|
||||
enableOfflineQueue: false,
|
||||
lazyConnect: false,
|
||||
lazyConnect: true,
|
||||
maxRetriesPerRequest: 1,
|
||||
});
|
||||
this.client.on('error', () => undefined);
|
||||
|
||||
Reference in New Issue
Block a user