make health check more optimistic

This commit is contained in:
wphan
2023-11-28 16:59:18 -08:00
parent d5c2bc1b01
commit d1f2ad3538
2 changed files with 12 additions and 23 deletions

View File

@@ -134,11 +134,10 @@ const handleHealthCheck = async (req, res, next) => {
if (lastHealthCheckState) {
res.writeHead(200);
res.end('OK');
} else {
res.writeHead(500);
res.end(`NOK`);
lastHealthCheckPerformed = Date.now();
return;
}
return;
// always check if last check was unhealthy (give it another chance to recover)
}
const { lastSlotReceived, lastSlotReceivedMutex } = getSlotHealthCheckInfo();
@@ -149,7 +148,9 @@ const handleHealthCheck = async (req, res, next) => {
lastHealthCheckState = lastSlotReceived > lastHealthCheckSlot;
if (!lastHealthCheckState) {
logger.error(
`Unhealthy: lastSlot: ${lastSlotReceived}, lastHealthCheckSlot: ${lastHealthCheckSlot}`
`Unhealthy: lastSlot: ${lastSlotReceived}, lastHealthCheckSlot: ${lastHealthCheckSlot}, timeSinceLastCheck: ${
Date.now() - lastHealthCheckPerformed
} ms`
);
}