Child Node cameraDestroy fix
parent
ea19db901c
commit
2886e58918
|
@ -3,6 +3,7 @@ var http = require('http');
|
|||
var https = require('https');
|
||||
var express = require('express');
|
||||
module.exports = function(s,config,lang,app,io){
|
||||
const { cameraDestroy } = require('./monitor/utils.js')(s,config,lang)
|
||||
//setup Master for childNodes
|
||||
if(config.childNodes.enabled === true && config.childNodes.mode === 'master'){
|
||||
s.childNodes = {};
|
||||
|
@ -252,7 +253,7 @@ module.exports = function(s,config,lang,app,io){
|
|||
break;
|
||||
case'kill':
|
||||
s.initiateMonitorObject(d.d);
|
||||
s.cameraDestroy(s.group[d.d.ke].activeMonitors[d.d.id].spawn,d.d)
|
||||
cameraDestroy(d.d)
|
||||
var childNodeIp = s.group[d.d.ke].activeMonitors[d.d.id]
|
||||
break;
|
||||
case'sync':
|
||||
|
|
|
@ -12,6 +12,7 @@ const async = require("async");
|
|||
const URL = require('url')
|
||||
const { copyObject, createQueue } = require('./common.js')
|
||||
module.exports = function(s,config,lang){
|
||||
const { cameraDestroy } = require('./monitor/utils.js')(s,config,lang)
|
||||
const startMonitorInQueue = createQueue(1, 3)
|
||||
s.initiateMonitorObject = function(e){
|
||||
if(!s.group[e.ke]){s.group[e.ke]={}};
|
||||
|
@ -371,87 +372,6 @@ module.exports = function(s,config,lang){
|
|||
})
|
||||
return items
|
||||
}
|
||||
|
||||
const cameraDestroy = function(e,p){
|
||||
if(s.group[e.ke]&&s.group[e.ke].activeMonitors[e.id]&&s.group[e.ke].activeMonitors[e.id].spawn !== undefined){
|
||||
const activeMonitor = s.group[e.ke].activeMonitors[e.id];
|
||||
const proc = s.group[e.ke].activeMonitors[e.id].spawn;
|
||||
if(proc){
|
||||
activeMonitor.allowStdinWrite = false
|
||||
s.txToDashcamUsers({
|
||||
f : 'disable_stream',
|
||||
ke : e.ke,
|
||||
mid : e.id
|
||||
},e.ke)
|
||||
// if(activeMonitor.p2pStream){activeMonitor.p2pStream.unpipe();}
|
||||
try{
|
||||
proc.removeListener('end',activeMonitor.spawn_exit);
|
||||
proc.removeListener('exit',activeMonitor.spawn_exit);
|
||||
delete(activeMonitor.spawn_exit);
|
||||
}catch(er){
|
||||
|
||||
}
|
||||
}
|
||||
if(activeMonitor.audioDetector){
|
||||
activeMonitor.audioDetector.stop()
|
||||
delete(activeMonitor.audioDetector)
|
||||
}
|
||||
activeMonitor.firstStreamChunk = {}
|
||||
clearTimeout(activeMonitor.recordingChecker);
|
||||
delete(activeMonitor.recordingChecker);
|
||||
clearTimeout(activeMonitor.streamChecker);
|
||||
delete(activeMonitor.streamChecker);
|
||||
clearTimeout(activeMonitor.checkSnap);
|
||||
delete(activeMonitor.checkSnap);
|
||||
clearTimeout(activeMonitor.watchdog_stop);
|
||||
delete(activeMonitor.watchdog_stop);
|
||||
delete(activeMonitor.lastJpegDetectorFrame);
|
||||
delete(activeMonitor.detectorFrameSaveBuffer);
|
||||
clearTimeout(activeMonitor.recordingSnapper);
|
||||
clearInterval(activeMonitor.getMonitorCpuUsage);
|
||||
clearInterval(activeMonitor.objectCountIntervals);
|
||||
delete(activeMonitor.onvifConnection)
|
||||
if(activeMonitor.onChildNodeExit){
|
||||
activeMonitor.onChildNodeExit()
|
||||
}
|
||||
activeMonitor.spawn.stdio.forEach(function(stdio){
|
||||
try{
|
||||
stdio.unpipe()
|
||||
}catch(err){
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
if(activeMonitor.mp4frag){
|
||||
var mp4FragChannels = Object.keys(activeMonitor.mp4frag)
|
||||
mp4FragChannels.forEach(function(channel){
|
||||
activeMonitor.mp4frag[channel].removeAllListeners()
|
||||
delete(activeMonitor.mp4frag[channel])
|
||||
})
|
||||
}
|
||||
if(config.childNodes.enabled === true && config.childNodes.mode === 'child' && config.childNodes.host){
|
||||
s.cx({f:'clearCameraFromActiveList',ke:e.ke,id:e.id})
|
||||
}
|
||||
if(activeMonitor.childNode){
|
||||
s.cx({f:'kill',d:s.cleanMonitorObject(e)},activeMonitor.childNodeId)
|
||||
}else{
|
||||
s.coSpawnClose(e)
|
||||
if(proc && proc.kill){
|
||||
if(s.isWin){
|
||||
spawn("taskkill", ["/pid", proc.pid, '/t'])
|
||||
}else{
|
||||
proc.kill('SIGTERM')
|
||||
}
|
||||
setTimeout(function(){
|
||||
try{
|
||||
proc.kill()
|
||||
}catch(err){
|
||||
s.debugLog(err)
|
||||
}
|
||||
},1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const checkObjectsInDetails = function(e){
|
||||
//parse Objects
|
||||
(['detector_cascades','cords','detector_filters','input_map_choices']).forEach(function(v){
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
module.exports = (s,config,lang) => {
|
||||
const cameraDestroy = function(e,p){
|
||||
if(
|
||||
s.group[e.ke] &&
|
||||
s.group[e.ke].activeMonitors[e.id] &&
|
||||
s.group[e.ke].activeMonitors[e.id].spawn !== undefined
|
||||
){
|
||||
const activeMonitor = s.group[e.ke].activeMonitors[e.id];
|
||||
const proc = s.group[e.ke].activeMonitors[e.id].spawn;
|
||||
if(proc){
|
||||
activeMonitor.allowStdinWrite = false
|
||||
s.txToDashcamUsers({
|
||||
f : 'disable_stream',
|
||||
ke : e.ke,
|
||||
mid : e.id
|
||||
},e.ke)
|
||||
// if(activeMonitor.p2pStream){activeMonitor.p2pStream.unpipe();}
|
||||
try{
|
||||
proc.removeListener('end',activeMonitor.spawn_exit);
|
||||
proc.removeListener('exit',activeMonitor.spawn_exit);
|
||||
delete(activeMonitor.spawn_exit);
|
||||
}catch(er){
|
||||
|
||||
}
|
||||
}
|
||||
if(activeMonitor.audioDetector){
|
||||
activeMonitor.audioDetector.stop()
|
||||
delete(activeMonitor.audioDetector)
|
||||
}
|
||||
activeMonitor.firstStreamChunk = {}
|
||||
clearTimeout(activeMonitor.recordingChecker);
|
||||
delete(activeMonitor.recordingChecker);
|
||||
clearTimeout(activeMonitor.streamChecker);
|
||||
delete(activeMonitor.streamChecker);
|
||||
clearTimeout(activeMonitor.checkSnap);
|
||||
delete(activeMonitor.checkSnap);
|
||||
clearTimeout(activeMonitor.watchdog_stop);
|
||||
delete(activeMonitor.watchdog_stop);
|
||||
delete(activeMonitor.lastJpegDetectorFrame);
|
||||
delete(activeMonitor.detectorFrameSaveBuffer);
|
||||
clearTimeout(activeMonitor.recordingSnapper);
|
||||
clearInterval(activeMonitor.getMonitorCpuUsage);
|
||||
clearInterval(activeMonitor.objectCountIntervals);
|
||||
delete(activeMonitor.onvifConnection)
|
||||
if(activeMonitor.onChildNodeExit){
|
||||
activeMonitor.onChildNodeExit()
|
||||
}
|
||||
activeMonitor.spawn.stdio.forEach(function(stdio){
|
||||
try{
|
||||
stdio.unpipe()
|
||||
}catch(err){
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
if(activeMonitor.mp4frag){
|
||||
var mp4FragChannels = Object.keys(activeMonitor.mp4frag)
|
||||
mp4FragChannels.forEach(function(channel){
|
||||
activeMonitor.mp4frag[channel].removeAllListeners()
|
||||
delete(activeMonitor.mp4frag[channel])
|
||||
})
|
||||
}
|
||||
if(config.childNodes.enabled === true && config.childNodes.mode === 'child' && config.childNodes.host){
|
||||
s.cx({f:'clearCameraFromActiveList',ke:e.ke,id:e.id})
|
||||
}
|
||||
if(activeMonitor.childNode){
|
||||
s.cx({f:'kill',d:s.cleanMonitorObject(e)},activeMonitor.childNodeId)
|
||||
}else{
|
||||
s.coSpawnClose(e)
|
||||
if(proc && proc.kill){
|
||||
if(s.isWin){
|
||||
spawn("taskkill", ["/pid", proc.pid, '/t'])
|
||||
}else{
|
||||
proc.kill('SIGTERM')
|
||||
}
|
||||
setTimeout(function(){
|
||||
try{
|
||||
proc.kill()
|
||||
}catch(err){
|
||||
s.debugLog(err)
|
||||
}
|
||||
},1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
cameraDestroy: cameraDestroy
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue