health check logs
This commit is contained in:
@@ -165,12 +165,16 @@ const handleHealthCheck = (
|
|||||||
|
|
||||||
// healthy if slot has advanced since the last check
|
// healthy if slot has advanced since the last check
|
||||||
const lastSlotReceived = slotSource.getSlot();
|
const lastSlotReceived = slotSource.getSlot();
|
||||||
|
const inGracePeriod =
|
||||||
|
Date.now() - lastTimeHealthy <= healthCheckGracePeriod;
|
||||||
lastHealthCheckState = lastSlotReceived > lastHealthCheckSlot;
|
lastHealthCheckState = lastSlotReceived > lastHealthCheckSlot;
|
||||||
if (!lastHealthCheckState) {
|
if (!lastHealthCheckState) {
|
||||||
logger.error(
|
logger.error(
|
||||||
`Unhealthy: lastSlot: ${lastSlotReceived}, lastHealthCheckSlot: ${lastHealthCheckSlot}, timeSinceLastCheck: ${
|
`Unhealthy: lastSlot: ${lastSlotReceived}, lastHealthCheckSlot: ${lastHealthCheckSlot}, timeSinceLastCheck: ${
|
||||||
Date.now() - lastHealthCheckPerformed
|
Date.now() - lastHealthCheckPerformed
|
||||||
} ms`
|
} ms, sinceLastTimeHealthy: ${
|
||||||
|
Date.now() - lastTimeHealthy
|
||||||
|
} ms, inGracePeriod: ${inGracePeriod}`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
lastTimeHealthy = Date.now();
|
lastTimeHealthy = Date.now();
|
||||||
@@ -179,10 +183,7 @@ const handleHealthCheck = (
|
|||||||
lastHealthCheckSlot = lastSlotReceived;
|
lastHealthCheckSlot = lastSlotReceived;
|
||||||
lastHealthCheckPerformed = Date.now();
|
lastHealthCheckPerformed = Date.now();
|
||||||
|
|
||||||
if (
|
if (!lastHealthCheckState && !inGracePeriod) {
|
||||||
!lastHealthCheckState &&
|
|
||||||
Date.now() - lastTimeHealthy > healthCheckGracePeriod
|
|
||||||
) {
|
|
||||||
healthStatus = HEALTH_STATUS.UnhealthySlotSubscriber;
|
healthStatus = HEALTH_STATUS.UnhealthySlotSubscriber;
|
||||||
|
|
||||||
res.writeHead(500);
|
res.writeHead(500);
|
||||||
|
|||||||
Reference in New Issue
Block a user