添加Health健康检查端点

This commit is contained in:
CN-JS-HuiBai
2026-04-05 21:13:27 +08:00
parent a103c7dbf5
commit e8e23c5af8
3 changed files with 68 additions and 2 deletions

View File

@@ -63,6 +63,17 @@ const cache = {
} catch (e) {
// ignore
}
},
async checkHealth() {
if (!redis) return { status: 'down', error: 'Valkey client not initialized' };
try {
const result = await redis.ping();
if (result === 'PONG') return { status: 'up' };
return { status: 'down', error: 'Invalid ping response' };
} catch (e) {
return { status: 'down', error: e.message };
}
}
};