Hourly check for possible stale sizePurge lock+

merge-requests/49/head
Moe 2019-01-23 21:33:55 -08:00
parent 107893d058
commit fe3121a7a8
1 changed files with 24 additions and 15 deletions

View File

@ -322,20 +322,29 @@ 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)
if(config.cron.deleteOverMax === true){
s.checkForStalePurgeLocks = function(){
var doCheck = function(){
Object.keys(s.group).forEach(function(groupKey){
var userGroup = s.group[groupKey]
var monitorCount = 10
if(userGroup.mon)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)
}
})
}
clearTimeout(s.checkForStalePurgeLocksInterval)
s.checkForStalePurgeLocksInterval = setInterval(function(){
doCheck()
},1000 * 60 * 60)
doCheck()
}
}else{
s.checkForStalePurgeLocks = function(){}
}
}