add !dead condition for childNode selector
+ make getChildNodes response cleanermerge-requests/117/head
parent
5a667d9cf2
commit
c777f85475
|
@ -46,6 +46,7 @@ module.exports = function(s,config,lang,app,io){
|
|||
s.childNodes[cn.ip].dead = false
|
||||
s.childNodes[cn.ip].cnid = cn.id
|
||||
s.childNodes[cn.ip].cpu = 0
|
||||
s.childNodes[cn.ip].ip = ipAddress
|
||||
s.childNodes[cn.ip].activeCameras = {}
|
||||
d.availableHWAccels.forEach(function(accel){
|
||||
if(config.availableHWAccels.indexOf(accel) === -1)config.availableHWAccels.push(accel)
|
||||
|
|
|
@ -1365,7 +1365,7 @@ module.exports = function(s,config,lang){
|
|||
var nodeWithLowestActiveCameras = null
|
||||
childNodeList.forEach(function(ip){
|
||||
var nodeCameraCount = Object.keys(s.childNodes[ip].activeCameras).length
|
||||
if(nodeCameraCount < nodeWithLowestActiveCamerasCount && s.childNodes[ip].cpu < 75){
|
||||
if(!s.childNodes[ip].dead && nodeCameraCount < nodeWithLowestActiveCamerasCount && s.childNodes[ip].cpu < 75){
|
||||
nodeWithLowestActiveCamerasCount = nodeCameraCount
|
||||
nodeWithLowestActiveCameras = ip
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ var spawn = require('child_process').spawn;
|
|||
var exec = require('child_process').exec;
|
||||
module.exports = function(s,config,lang){
|
||||
s.purgeDiskForGroup = function(e){
|
||||
if(config.cron.deleteOverMax === true){
|
||||
if(config.cron.deleteOverMax === true && s.group[e.ke] && s.group[e.ke].sizePurgeQueue){
|
||||
s.group[e.ke].sizePurgeQueue.push(1)
|
||||
if(s.group[e.ke].sizePurging !== true){
|
||||
s.group[e.ke].sizePurging = true
|
||||
|
|
|
@ -639,9 +639,35 @@ module.exports = function(s,config,lang,app){
|
|||
*/
|
||||
app.all(config.webPaths.superApiPrefix+':auth/getChildNodes', function (req,res){
|
||||
s.superAuth(req.params,function(resp){
|
||||
var childNodesJson = {}
|
||||
Object.values(s.childNodes).forEach(function(activeNode){
|
||||
var activeCamerasCount = 0
|
||||
var activeCameras = {}
|
||||
Object.values(activeNode.activeCameras).forEach(function(monitor){
|
||||
++activeCamerasCount
|
||||
if(!activeCameras[monitor.ke])activeCameras[monitor.ke] = {}
|
||||
activeCameras[monitor.ke][monitor.mid] = {
|
||||
name: monitor.name,
|
||||
mid: monitor.mid,
|
||||
ke: monitor.ke,
|
||||
details: {
|
||||
accelerator: monitor.details.accelerator,
|
||||
auto_host: monitor.details.auto_host,
|
||||
}
|
||||
}
|
||||
})
|
||||
childNodesJson[activeNode.ip] = {
|
||||
ip: activeNode.ip,
|
||||
cpu: activeNode.cpu,
|
||||
dead: activeNode.dead,
|
||||
countCount: activeNode.countCount,
|
||||
activeMonitorsCount: activeCamerasCount,
|
||||
activeMonitors: activeCameras,
|
||||
}
|
||||
})
|
||||
var endData = {
|
||||
ok : true,
|
||||
childNode: s.childNodes,
|
||||
childNodes: childNodesJson,
|
||||
}
|
||||
res.end(s.prettyPrint(endData))
|
||||
},res,req)
|
||||
|
|
Loading…
Reference in New Issue