This commit is contained in:
Dave Horton
2020-02-19 11:15:24 -05:00
parent 162dfff5a3
commit 802cc1944f
11 changed files with 1013 additions and 917 deletions

View File

@@ -1,12 +1,12 @@
const ip = require('ip');
const localIp = ip.address();
const PORT = process.env.HTTP_PORT || 3000;
const assert = require('assert');
function installSrfLocals(srf, logger) {
if (srf.locals.dbHelpers) return;
assert(!srf.locals.dbHelpers);
const {getSBC, getSrf} = require('./sbc-pinger')(logger);
const freeswitch = process.env.JAMBONES_FREESWITCH
.split(',')
.map((fs) => {
@@ -15,6 +15,9 @@ function installSrfLocals(srf, logger) {
});
logger.info({freeswitch}, 'freeswitch inventory');
const StatsCollector = require('jambonz-stats-collector');
const stats = srf.locals.stats = new StatsCollector(logger);
const {
lookupAppByPhoneNumber,
lookupAppBySid,
@@ -51,8 +54,11 @@ function installSrfLocals(srf, logger) {
serviceUrl: `http://${localIp}:${PORT}`,
getSBC,
getSrf,
getFreeswitch: () => freeswitch[0]
getFreeswitch: () => freeswitch[0],
stats: stats
});
logger.debug({locals: srf.locals}, 'srf.locals installed');
}
module.exports = installSrfLocals;