fix Command on Event timeout

merge-requests/116/head
Moe 2019-09-04 18:20:06 -07:00
parent 5908830f39
commit 085b6df7d9
2 changed files with 7 additions and 7 deletions

View File

@ -233,7 +233,7 @@ module.exports = function(s,config){
break;
}
}
s.createTimeout = function(timeoutVar,timeoutLength,defaultLength,multiplier,callback){
s.createTimeout = function(timeoutVar,parentVar,timeoutLength,defaultLength,multiplier,callback){
var theTimeout
if(!multiplier)multiplier = 1000 * 60
if(!timeoutLength || timeoutLength === ''){
@ -241,13 +241,13 @@ module.exports = function(s,config){
}else{
theTimeout = parseFloat(timeoutLength) * multiplier
}
clearTimeout(timeoutVar)
timeoutVar = setTimeout(function(){
clearTimeout(timeoutVar)
delete(timeoutVar)
clearTimeout(parentVar[timeoutVar])
parentVar[timeoutVar] = setTimeout(function(){
clearTimeout(parentVar[timeoutVar])
delete(parentVar[timeoutVar])
if(callback)callback()
},theTimeout)
return timeoutVar
return parentVar[timeoutVar]
}
s.isCorrectFilenameSyntax = function(string){
return RegExp('[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]-[0-9][0-9]-[0-9][0-9]').test(string)

View File

@ -325,7 +325,7 @@ module.exports = function(s,config,lang){
}
if(filter.command && currentConfig.detector_command_enable === '1' && !s.group[d.ke].activeMonitors[d.id].detector_command){
s.group[d.ke].activeMonitors[d.id].detector_command = s.createTimeout(s.group[d.ke].activeMonitors[d.id].detector_command,currentConfig.detector_command_timeout,10)
s.group[d.ke].activeMonitors[d.id].detector_command = s.createTimeout('detector_command',s.group[d.ke].activeMonitors[d.id],currentConfig.detector_command_timeout,10)
var detector_command = addEventDetailsToString(d,currentConfig.detector_command)
if(detector_command === '')return
exec(detector_command,{detached: true},function(err){