From fdce05fa40fa166e56c8a18e9cf0825937699254 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Tue, 30 Dec 2025 13:31:42 -0500 Subject: [PATCH] add handler for SIGUSR1 to start drying up calls, useful as a generic mechanism on non-AWS deployments (#1482) --- lib/utils/sbc-pinger.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/utils/sbc-pinger.js b/lib/utils/sbc-pinger.js index 729dcb5c..3b4d6f17 100644 --- a/lib/utils/sbc-pinger.js +++ b/lib/utils/sbc-pinger.js @@ -100,6 +100,39 @@ module.exports = (logger) => { else if (K8S) { lifecycleEmitter.scaleIn = () => process.exit(0); } + else { + process.on('SIGUSR1', () => { + logger.info('received SIGUSR1: begin drying up calls for scale-in'); + dryUpCalls = true; + + const {srf} = require('../..'); + const {writeSystemAlerts} = srf.locals; + if (writeSystemAlerts) { + const {SystemState, FEATURE_SERVER} = require('./constants'); + writeSystemAlerts({ + system_component: FEATURE_SERVER, + state : SystemState.GracefulShutdownInProgress, + fields : { + detail: `feature-server with process_id ${process.pid} shutdown in progress`, + host: srf.locals?.ipv4 + } + }); + } + pingProxies(srf); + + // if we have zero calls, we can complete the scale-in right + setTimeout(() => { + const calls = srf.locals.sessionTracker.count; + if (calls === 0) { + logger.info('scale-in can complete immediately as we have no calls in progress'); + process.exit(0); + } + else { + logger.info(`${calls} calls in progress; scale-in will complete when they are done`); + } + }, 5000); + }); + } async function pingProxies(srf) {