mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2026-01-25 02:07:56 +00:00
add handler for SIGUSR1 to start drying up calls, useful as a generic mechanism on non-AWS deployments (#1482)
This commit is contained in:
@@ -100,6 +100,39 @@ module.exports = (logger) => {
|
|||||||
else if (K8S) {
|
else if (K8S) {
|
||||||
lifecycleEmitter.scaleIn = () => process.exit(0);
|
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) {
|
async function pingProxies(srf) {
|
||||||
|
|||||||
Reference in New Issue
Block a user