Merge branch 'mainnet-beta'

This commit is contained in:
wphan
2023-11-24 16:15:26 -08:00
2 changed files with 14 additions and 3 deletions

View File

@@ -126,9 +126,11 @@ const handleHealthCheck = async (req, res, next) => {
if (req.url === '/health' || req.url === '/') { if (req.url === '/health' || req.url === '/') {
// check if a slot was received recently // check if a slot was received recently
let healthySlotSubscriber = false; let healthySlotSubscriber = false;
let slotChanged = false;
let slotChangedRecently = false;
await lastSlotReceivedMutex.runExclusive(async () => { await lastSlotReceivedMutex.runExclusive(async () => {
const slotChanged = lastSlotReceived > lastHealthCheckSlot; slotChanged = lastSlotReceived > lastHealthCheckSlot;
const slotChangedRecently = slotChangedRecently =
Date.now() - lastHealthCheckSlotUpdated < healthCheckInterval; Date.now() - lastHealthCheckSlotUpdated < healthCheckInterval;
healthySlotSubscriber = slotChanged || slotChangedRecently; healthySlotSubscriber = slotChanged || slotChangedRecently;
logger.debug( logger.debug(
@@ -142,6 +144,9 @@ const handleHealthCheck = async (req, res, next) => {
if (!healthySlotSubscriber) { if (!healthySlotSubscriber) {
healthStatus = HEALTH_STATUS.UnhealthySlotSubscriber; healthStatus = HEALTH_STATUS.UnhealthySlotSubscriber;
logger.error(`SlotSubscriber is not healthy`); logger.error(`SlotSubscriber is not healthy`);
logger.error(
`Slotsubscriber health check: lastSlotReceived: ${lastSlotReceived}, lastHealthCheckSlot: ${lastHealthCheckSlot}, slotChanged: ${slotChanged}, slotChangedRecently: ${slotChangedRecently}`
);
res.writeHead(500); res.writeHead(500);
res.end(`SlotSubscriber is not healthy`); res.end(`SlotSubscriber is not healthy`);

View File

@@ -12,7 +12,6 @@ import {
DriftClient, DriftClient,
initialize, initialize,
DriftEnv, DriftEnv,
SlotSubscriber,
UserMap, UserMap,
DLOBOrder, DLOBOrder,
DLOBOrders, DLOBOrders,
@@ -104,6 +103,13 @@ app.use((req, _res, next) => {
app.use(errorHandler); app.use(errorHandler);
const server = http.createServer(app); const server = http.createServer(app);
// Default keepalive is 5s, since the AWS ALB timeout is 60 seconds, clients
// sometimes get 502s.
// https://shuheikagawa.com/blog/2019/04/25/keep-alive-timeout/
// https://stackoverflow.com/a/68922692
server.keepAliveTimeout = 61 * 1000;
server.headersTimeout = 65 * 1000;
const opts = program.opts(); const opts = program.opts();
setLogLevel(opts.debug ? 'debug' : 'info'); setLogLevel(opts.debug ? 'debug' : 'info');