Compare commits

...

5 Commits

Author SHA1 Message Date
Sam Machin
b3759d9c81 lint 2025-07-29 10:05:45 -04:00
Sam Machin
41106ddfc1 disable node.js cleanup 2025-07-29 10:05:45 -04:00
Sam Machin
55939752e2 lint 2025-07-29 10:05:45 -04:00
Sam Machin
f03ec420bf lint 2025-07-29 10:05:45 -04:00
Sam Machin
10a2b15279 Update cron-jobs.js 2025-07-29 10:05:45 -04:00
3 changed files with 27 additions and 28 deletions

27
app.js
View File

@@ -5,8 +5,6 @@ const {
JAMBONES_OTEL_SERVICE_NAME, JAMBONES_OTEL_SERVICE_NAME,
JAMBONES_LOGLEVEL, JAMBONES_LOGLEVEL,
JAMBONES_CLUSTER_ID, JAMBONES_CLUSTER_ID,
JAMBONZ_CLEANUP_INTERVAL_MINS,
getCleanupIntervalMins,
K8S, K8S,
NODE_ENV, NODE_ENV,
checkEnvs, checkEnvs,
@@ -204,17 +202,20 @@ async function handle(signal) {
} }
} }
if (JAMBONZ_CLEANUP_INTERVAL_MINS) { // Disabled in favour of OS Level Cron Job, TODO Remove in later release
const {clearFiles} = require('./lib/utils/cron-jobs'); //
//if (JAMBONZ_CLEANUP_INTERVAL_MINS) {
// const {clearFiles} = require('./lib/utils/cron-jobs');
// /* cleanup orphaned files or channels every so often */
// setInterval(async() => {
// try {
// await clearFiles();
// } catch (err) {
// logger.error({err}, 'app.js: error clearing files');
// }
// }, getCleanupIntervalMins());
//}
/* cleanup orphaned files or channels every so often */
setInterval(async() => {
try {
await clearFiles();
} catch (err) {
logger.error({err}, 'app.js: error clearing files');
}
}, getCleanupIntervalMins());
}
module.exports = {srf, logger, disconnect}; module.exports = {srf, logger, disconnect};

View File

@@ -82,11 +82,11 @@ const K8S_SBC_SIP_SERVICE_NAME = process.env.K8S_SBC_SIP_SERVICE_NAME;
const JAMBONES_SUBNET = process.env.JAMBONES_SUBNET; const JAMBONES_SUBNET = process.env.JAMBONES_SUBNET;
/* clean up */ /* clean up */
const JAMBONZ_CLEANUP_INTERVAL_MINS = process.env.JAMBONZ_CLEANUP_INTERVAL_MINS; //const JAMBONZ_CLEANUP_INTERVAL_MINS = process.env.JAMBONZ_CLEANUP_INTERVAL_MINS;
const getCleanupIntervalMins = () => { //const getCleanupIntervalMins = () => {
const interval = parseInt(JAMBONZ_CLEANUP_INTERVAL_MINS, 10) || 60; // const interval = parseInt(JAMBONZ_CLEANUP_INTERVAL_MINS, 10) || 60;
return 1000 * 60 * interval; // return 1000 * 60 * interval;
}; //};
/* speech vendors */ /* speech vendors */
const AWS_REGION = process.env.AWS_REGION; const AWS_REGION = process.env.AWS_REGION;
@@ -184,8 +184,6 @@ module.exports = {
K8S_SBC_SIP_SERVICE_NAME, K8S_SBC_SIP_SERVICE_NAME,
JAMBONES_SUBNET, JAMBONES_SUBNET,
NODE_ENV, NODE_ENV,
JAMBONZ_CLEANUP_INTERVAL_MINS,
getCleanupIntervalMins,
checkEnvs, checkEnvs,
AWS_REGION, AWS_REGION,

View File

@@ -2,7 +2,7 @@ const {execSync} = require('child_process');
const { const {
JAMBONES_FREESWITCH, JAMBONES_FREESWITCH,
NODE_ENV, NODE_ENV,
JAMBONES_FREESWITCH_MAX_CALL_DURATION_MINS, JAMBONES_FREESWITCH_MAX_CALL_DURATION_MINS
} = require('../config'); } = require('../config');
const now = Date.now(); const now = Date.now();
const fsInventory = JAMBONES_FREESWITCH const fsInventory = JAMBONES_FREESWITCH
@@ -46,12 +46,12 @@ const clearChannels = () => {
return calls.length; return calls.length;
}; };
const clearFiles = () => { // Disabled in favour of OS Level Cron Job, TODO Remove in later release
//const {logger} = require('../..'); //const clearFiles = () => {
/*const out = */ execSync('find /tmp -name "*.mp3" -mtime +2 -exec rm {} \\;'); // //const {logger} = require('../..');
//logger.debug({out}, 'clearFiles: command output'); // /*const out = */ execSync('find /tmp -name "*.mp3" -mtime +2 -exec rm {} \\;');
}; // //logger.debug({out}, 'clearFiles: command output');
//}
module.exports = {clearChannels };
module.exports = {clearChannels, clearFiles};