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