consider Monitor->Controllable as well in stopping zmtrack. Don't complain about ControlCommand being told to start/stop

This commit is contained in:
Isaac Connor 2020-07-20 10:23:26 -04:00
parent 5c844f9cae
commit cb0e54d3be
1 changed files with 8 additions and 8 deletions

View File

@ -298,12 +298,12 @@ class Monitor extends ZM_Object {
return; return;
} }
} }
Logger::Debug("sending command to $url"); Logger::Debug('sending command to '.$url);
$context = stream_context_create(); $context = stream_context_create();
try { try {
$result = file_get_contents($url, false, $context); $result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ if ( $result === FALSE ) { /* Handle error */
Error("Error restarting zmc using $url"); Error("Error restarting zmc using $url");
} }
} catch ( Exception $e ) { } catch ( Exception $e ) {
@ -315,14 +315,15 @@ class Monitor extends ZM_Object {
} // end function zmcControl } // end function zmcControl
function zmaControl($mode=false) { function zmaControl($mode=false) {
if ( ! $this->{'Id'} ) { if ( !$this->{'Id'} ) {
Warning('Attempt to control a monitor with no Id'); Warning('Attempt to control a monitor with no Id');
return; return;
} }
if ( (!defined('ZM_SERVER_ID')) or ( property_exists($this, 'ServerId') and (ZM_SERVER_ID==$this->{'ServerId'}) ) ) { if ( (!defined('ZM_SERVER_ID')) or ( property_exists($this, 'ServerId') and (ZM_SERVER_ID==$this->{'ServerId'}) ) ) {
if ( $this->{'Function'} == 'None' || $this->{'Function'} == 'Monitor' || $mode == 'stop' ) { if ( $this->{'Function'} == 'None' || $this->{'Function'} == 'Monitor' || $mode == 'stop' ) {
if ( ZM_OPT_CONTROL ) { if ( ZM_OPT_CONTROL && $this->Controllable() && $this->TrackMotion() &&
( $this->{'Function'} == 'Modect' || $this->{'Function'} == 'Mocord' ) ) {
daemonControl('stop', 'zmtrack.pl', '-m '.$this->{'Id'}); daemonControl('stop', 'zmtrack.pl', '-m '.$this->{'Id'});
} }
daemonControl('stop', 'zma', '-m '.$this->{'Id'}); daemonControl('stop', 'zma', '-m '.$this->{'Id'});
@ -362,7 +363,7 @@ class Monitor extends ZM_Object {
$context = stream_context_create(); $context = stream_context_create();
try { try {
$result = file_get_contents($url, false, $context); $result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ if ( $result === FALSE ) { /* Handle error */
Error("Error restarting zma using $url"); Error("Error restarting zma using $url");
} }
} catch ( Exception $e ) { } catch ( Exception $e ) {
@ -495,12 +496,11 @@ class Monitor extends ZM_Object {
foreach ( explode(' ', $command) as $option ) { foreach ( explode(' ', $command) as $option ) {
if ( preg_match('/--([^=]+)(?:=(.+))?/', $option, $matches) ) { if ( preg_match('/--([^=]+)(?:=(.+))?/', $option, $matches) ) {
$options[$matches[1]] = $matches[2]?$matches[2]:1; $options[$matches[1]] = $matches[2]?$matches[2]:1;
} else if ( $option != '' and $option != 'quit' ) { } else if ( $option != '' and $option != 'quit' and $option != 'start' and $option != 'stop' ) {
Warning("Ignored command for zmcontrol $option in $command"); Warning("Ignored command for zmcontrol $option in $command");
} }
} }
if ( !count($options) ) { if ( !count($options) ) {
if ( $command == 'quit' or $command == 'start' or $command == 'stop' ) { if ( $command == 'quit' or $command == 'start' or $command == 'stop' ) {
# These are special as we now run zmcontrol as a daemon through zmdc. # These are special as we now run zmcontrol as a daemon through zmdc.
$status = daemonStatus('zmcontrol.pl', array('--id', $this->{'Id'})); $status = daemonStatus('zmcontrol.pl', array('--id', $this->{'Id'}));