reduce dlob publisher health check grace period, clean up logs
This commit is contained in:
@@ -181,9 +181,7 @@ export const setHealthStatus = (status: HEALTH_STATUS): void => {
|
||||
* We may be hit by multiple sources performing health checks on us, so this middleware will latch
|
||||
* to its health state and only update every `healthCheckInterval`.
|
||||
*
|
||||
* A grace period is also used to only report unhealthy if we have been unhealthy for a certain
|
||||
* amount of time. This prevents reporting unhealthy even if we are just in the middle of a
|
||||
* bulk account load.
|
||||
* A grace period is also used to only report unhealthy if we have been unhealthy beyond the grace period.
|
||||
*/
|
||||
const handleHealthCheck = (
|
||||
healthCheckGracePeriod: number,
|
||||
@@ -191,6 +189,7 @@ const handleHealthCheck = (
|
||||
) => {
|
||||
return async (_req, res, _next) => {
|
||||
if (healthStatus === HEALTH_STATUS.Restart) {
|
||||
logger.error(`Health status: Restart`);
|
||||
res.writeHead(500);
|
||||
res.end(`NOK`);
|
||||
return;
|
||||
|
||||
@@ -221,10 +221,9 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
||||
!skipSlotCheck &&
|
||||
!isPerpMarketAndPrelaunchMarket
|
||||
) {
|
||||
console.log(`Unhealthy process due to slot diffs for market ${marketName}:
|
||||
dlobProvider slot: ${slot}
|
||||
oracle slot: ${l2Formatted['oracleData']['slot']}
|
||||
`);
|
||||
console.log(
|
||||
`Unhealthy process due to slot diffs for market ${marketName}. dlobProviderSlot: ${slot}, oracleSlot: ${l2Formatted['oracleData']['slot']}`
|
||||
);
|
||||
setHealthStatus(HEALTH_STATUS.Restart);
|
||||
}
|
||||
|
||||
@@ -239,10 +238,9 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
||||
Date.now() - lastMarketSlotAndTime.ts > MAKRET_STALENESS_THRESHOLD &&
|
||||
!skipSlotCheck
|
||||
) {
|
||||
console.log(`Unhealthy process due to same slot for market ${marketName} after > ${MAKRET_STALENESS_THRESHOLD}ms:
|
||||
dlobProvider slot: ${slot}
|
||||
market slot: ${l2Formatted['marketSlot']}
|
||||
`);
|
||||
console.log(
|
||||
`Unhealthy process due to same slot for market ${marketName} after > ${MAKRET_STALENESS_THRESHOLD}ms. dlobProviderSlot: ${slot}, marketSlot: ${l2Formatted['marketSlot']}`
|
||||
);
|
||||
setHealthStatus(HEALTH_STATUS.Restart);
|
||||
} else if (
|
||||
lastMarketSlotAndTime &&
|
||||
|
||||
@@ -69,7 +69,9 @@ const clients = process.env.REDIS_CLIENT?.trim()
|
||||
|
||||
clients?.forEach((client) => envClients.push(RedisClientPrefix[client]));
|
||||
|
||||
const REDIS_CLIENTS = envClients.length ? envClients : [RedisClientPrefix.DLOB, RedisClientPrefix.DLOB_HELIUS];
|
||||
const REDIS_CLIENTS = envClients.length
|
||||
? envClients
|
||||
: [RedisClientPrefix.DLOB, RedisClientPrefix.DLOB_HELIUS];
|
||||
console.log('Redis Clients:', REDIS_CLIENTS);
|
||||
|
||||
const driftEnv = (process.env.ENV || 'devnet') as DriftEnv;
|
||||
|
||||
@@ -455,10 +455,10 @@ const main = async () => {
|
||||
|
||||
app.get(
|
||||
'/health',
|
||||
handleHealthCheck(2 * WS_FALLBACK_FETCH_INTERVAL, dlobProvider)
|
||||
handleHealthCheck(WS_FALLBACK_FETCH_INTERVAL, dlobProvider)
|
||||
);
|
||||
app.get('/startup', handleStartup);
|
||||
app.get('/', handleHealthCheck(2 * WS_FALLBACK_FETCH_INTERVAL, dlobProvider));
|
||||
app.get('/', handleHealthCheck(WS_FALLBACK_FETCH_INTERVAL, dlobProvider));
|
||||
const server = app.listen(8080);
|
||||
|
||||
// Default keepalive is 5s, since the AWS ALB timeout is 60 seconds, clients
|
||||
|
||||
@@ -45,7 +45,9 @@ const clients = process.env.REDIS_CLIENT?.trim()
|
||||
|
||||
clients?.forEach((client) => envClients.push(RedisClientPrefix[client]));
|
||||
|
||||
const REDIS_CLIENTS = envClients.length ? envClients : [RedisClientPrefix.DLOB, RedisClientPrefix.DLOB_HELIUS];
|
||||
const REDIS_CLIENTS = envClients.length
|
||||
? envClients
|
||||
: [RedisClientPrefix.DLOB, RedisClientPrefix.DLOB_HELIUS];
|
||||
console.log('Redis Clients:', REDIS_CLIENTS);
|
||||
|
||||
const driftEnv = (process.env.ENV || 'devnet') as DriftEnv;
|
||||
|
||||
Reference in New Issue
Block a user