mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
fix freeswitch retry connection logic
This commit is contained in:
@@ -53,8 +53,9 @@ function installSrfLocals(srf, logger) {
|
||||
// retry to connect to any that were initially offline
|
||||
setInterval(async() => {
|
||||
for (const val of mediaservers) {
|
||||
if (val.connect === 0) {
|
||||
if (val.connects === 0) {
|
||||
try {
|
||||
logger.info({mediaserver: val.opts}, 'Retrying initial connection to media server');
|
||||
const ms = await mrf.connect(val.opts);
|
||||
val.ms = ms;
|
||||
} catch (err) {
|
||||
@@ -66,13 +67,15 @@ function installSrfLocals(srf, logger) {
|
||||
|
||||
// if we have a single freeswitch (as is typical) report stats periodically
|
||||
if (mediaservers.length === 1) {
|
||||
const ms = mediaservers[0].ms;
|
||||
setInterval(() => {
|
||||
try {
|
||||
stats.gauge('fs.media.channels.in_use', ms.currentSessions);
|
||||
stats.gauge('fs.media.channels.free', ms.maxSessions - ms.currentSessions);
|
||||
stats.gauge('fs.media.calls_per_second', ms.cps);
|
||||
stats.gauge('fs.media.cpu_idle', ms.cpuIdle);
|
||||
if (mediaservers[0].ms && mediaservers[0].active) {
|
||||
const ms = mediaservers[0].ms;
|
||||
stats.gauge('fs.media.channels.in_use', ms.currentSessions);
|
||||
stats.gauge('fs.media.channels.free', ms.maxSessions - ms.currentSessions);
|
||||
stats.gauge('fs.media.calls_per_second', ms.cps);
|
||||
stats.gauge('fs.media.cpu_idle', ms.cpuIdle);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
logger.info(err, 'Error sending media server metrics');
|
||||
|
||||
Reference in New Issue
Block a user