bugfix: setting public ip and handling options ping

This commit is contained in:
Dave Horton
2020-04-20 16:34:54 -04:00
parent c1e4324b51
commit 203cd0d16b
2 changed files with 6 additions and 14 deletions

2
app.js
View File

@@ -48,7 +48,7 @@ if (process.env.DRACHTIO_HOST) {
const last = hp.split(',').pop();
const arr = /^(.*)\/(.*):(\d+)$/.exec(last);
logger.info(`connected to drachtio listening on ${hp}: adding ${arr[2]} to sbc_addresses table`);
addSbcAddress(arr[1]);
addSbcAddress(arr[2]);
});
}
else {

View File

@@ -21,17 +21,18 @@ module.exports = (srf, logger) => {
const status = req.get('X-FS-Status');
const calls = req.has('X-FS-Calls') ? parseInt(req.get('X-FS-Calls')) : 0;
if (status === 'open') {
if (!contacts.has(uri)) {
const adding = !contacts.has(uri);
debug(`Feature server at ${uri} has ${calls} calls`);
contacts.set(uri, {pingTime: new Date(), calls: calls});
if (adding) {
logger.info(`adding feature server at ${uri}`);
stats.gauge('sbc.featureservers.count', contacts.size + 1);
stats.gauge('sbc.featureservers.count', contacts.size);
const featureServerIps = [...contacts.keys()].map((uri) => {
const arr = /^(.*):\d+$/.exec(uri);
return arr[1];
});
createSet(setName, new Set(featureServerIps));
}
debug(`Feature server at ${uri} has ${calls} calls`);
contacts.set(uri, {pingTime: new Date(), calls: calls});
}
else {
if (contacts.has(uri)) {
@@ -48,15 +49,6 @@ module.exports = (srf, logger) => {
}
});
if (process.env.JAMBONES_FEATURE_SERVERS) {
dynamic = false;
process.env.JAMBONES_FEATURE_SERVERS
.split(',')
.map((hp) => hp.trim())
.forEach((uri) => contacts.set(uri, {active: 0, calls: 0}));
debug(`using static list of feature servers: ${[ ...contacts]}`);
}
if (dynamic) {
const CHECK_INTERVAL = 35;
setInterval(() => {