disable node.js cleanup

This commit is contained in:
Sam Machin
2025-07-25 12:02:20 +01:00
committed by Dave Horton
parent 55939752e2
commit 41106ddfc1
2 changed files with 22 additions and 21 deletions

25
app.js
View File

@@ -204,17 +204,20 @@ async function handle(signal) {
}
}
if (JAMBONZ_CLEANUP_INTERVAL_MINS) {
const {clearFiles} = require('./lib/utils/cron-jobs');
// Disabled in favour of OS Level Cron Job, TODO Remove in later release
//
//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};

View File

@@ -2,9 +2,7 @@ const {execSync} = require('child_process');
const {
JAMBONES_FREESWITCH,
NODE_ENV,
JAMBONES_FREESWITCH_MAX_CALL_DURATION_MINS,
TMP_FOLDER,
JAMBONZ_CLEANUP_INTERVAL_MINS
JAMBONES_FREESWITCH_MAX_CALL_DURATION_MINS
} = require('../config');
const now = Date.now();
const fsInventory = JAMBONES_FREESWITCH
@@ -48,12 +46,12 @@ const clearChannels = () => {
return calls.length;
};
const clearFiles = () => {
// Remove temp audiofiles that were not auto deleted older 300 min (or CLEANUP_INTERVAL if set) from TMP_FOLDER
const maxAge = JAMBONZ_CLEANUP_INTERVAL_MINS || 300;
execSync(`/usr/local/bin/cleanup-temp-audiofiles.sh ${maxAge} ${TMP_FOLDER};`);
};
// Disabled in favour of OS Level Cron Job, TODO Remove in later release
//const clearFiles = () => {
// //const {logger} = require('../..');
// /*const out = */ execSync('find /tmp -name "*.mp3" -mtime +2 -exec rm {} \\;');
// //logger.debug({out}, 'clearFiles: command output');
//}
module.exports = {clearChannels, clearFiles};
module.exports = {clearChannels };