Hourly check for possible stale sizePurge lock

merge-requests/49/head
Moe 2019-01-22 21:43:10 -08:00
parent 79e3632b88
commit 107893d058
5 changed files with 36 additions and 3 deletions

View File

@ -26,9 +26,9 @@ loadLib('codeTester')(s,config,lang,io)
//basic functions
loadLib('basic')(s,config)
//video processing engine
loadLib('ffmpeg')(s,config,function(){
loadLib('ffmpeg')(s,config,function(ffmpeg){
//ffmpeg coProcessor
loadLib('ffmpegCoProcessor')(s,config,lang)
loadLib('ffmpegCoProcessor')(s,config,lang,ffmpeg)
//database connection : mysql, sqlite3..
loadLib('sql')(s,config)
//working directories : videos, streams, fileBin..

View File

@ -422,6 +422,8 @@
"deleteMonitorStateText2": "Do you want to delete this Monitor's Preset?",
"Preset": "Preset",
"Presets": "Presets",
"possibleInternalError": "Possible Internal Error",
"sizePugeLockedText": "The Size Purge Lock (deleteOverMax) appears to have failed to unlock. Unlocking now...",
"Use coProcessor": "Use coProcessor",
"Audio Codec": "Audio Codec",
"Video Record Rate": "Video Record Rate <small>(FPS)</small>",

View File

@ -168,6 +168,9 @@ module.exports = function(s,config,lang,io,){
})
})
},10000)
//hourly check to see if sizePurge has failed to unlock
//checks to see if request count is the number of monitors + 10
s.checkForStalePurgeLocks()
//run prerequsite queries, load users and monitors
if(config.childNodes.mode !== 'child'){
//sql/database connection with knex

View File

@ -15,7 +15,7 @@ module.exports = function(s,config){
if(s.group[e.ke].sizePurgeQueue.length > 0){
checkQueue()
}else{
s.group[e.ke].sizePurging=false
s.group[e.ke].sizePurging = false
s.sendDiskUsedAmountToClients(e)
}
}
@ -322,4 +322,20 @@ module.exports = function(s,config){
callback(notFound,preset)
})
}
s.checkForStalePurgeLocks = function(){
clearTimeout(s.checkForStalePurgeLocksInterval)
s.checkForStalePurgeLocksInterval = setInterval(function(){
Object.keys(s.group).forEach(function(groupKey){
var userGroup = s.group[groupKey]
var monitorCount = Object.keys(userGroup.mon).length
var purgeRequestCount = userGroup.sizePurgeQueue.length
var isLocked = (userGroup.sizePurging === true)
if(isLocked && purgeRequestCount > monitorCount + 10){
s.group[groupKey].sizePurgeQueue = []
s.group[groupKey].sizePurging = false
s.systemLog(lang.sizePugeLockedText + ' : ' + groupKey)
}
})
},1000 * 60 * 60)
}
}

View File

@ -622,4 +622,16 @@ module.exports = function(s,config,lang,app){
}
},res,req)
})
/**
* API : Superuser : Force Check for Stale Purge Locks
*/
app.all(config.webPaths.superApiPrefix+':auth/system/checkForStalePurgeLocks', function (req,res){
s.superAuth(req.params,function(resp){
var endData = {
ok : true
}
s.checkForStalePurgeLocks()
res.end(s.prettyPrint(endData))
},res,req)
})
}