add custom headers to outdial, save unique uuid for running FS to redis

This commit is contained in:
Dave Horton
2022-01-08 11:50:18 -05:00
parent 3bf1984854
commit 8593f12b51
6 changed files with 20 additions and 9 deletions

View File

@@ -1,8 +1,9 @@
const assert = require('assert');
const noopLogger = {info: () => {}, error: () => {}};
const {LifeCycleEvents} = require('./constants');
const { v4: uuidv4 } = require('uuid');
const {LifeCycleEvents, FS_UUID_SET_NAME} = require('./constants');
const Emitter = require('events');
const debug = require('debug')('jambonz:feature-server');
const noopLogger = {info: () => {}, error: () => {}};
module.exports = (logger) => {
logger = logger || noopLogger;
@@ -89,9 +90,13 @@ module.exports = (logger) => {
}
}
}
const {srf} = require('../..');
if (process.env.K8S) {
logger.info('disabling OPTIONS pings since we are running as a kubernetes service');
const {addToSet} = srf.locals.dbHelpers;
const uuid = srf.locals.fsUUID = uuidv4();
addToSet(FS_UUID_SET_NAME, uuid)
.catch((err) => logger.info({err}, `Error adding ${uuid} to set ${FS_UUID_SET_NAME}`));
}
else {
// OPTIONS ping the SBCs from each feature server every 60 seconds
@@ -102,7 +107,6 @@ module.exports = (logger) => {
// initial ping once we are up
setTimeout(async() => {
const {srf} = require('../..');
// if SBCs are auto-scaling, monitor them as they come and go
if (!process.env.JAMBONES_SBCS) {