log error when execution of command fails

This commit is contained in:
Uwe Steinmann 2023-02-09 07:16:50 +01:00
parent 27b19f5c3a
commit 6fd8d3e7f5

View File

@ -49,6 +49,7 @@ class SeedDMS_ConversionServiceExec extends SeedDMS_ConversionServiceBase {
); );
$pipes = array(); $pipes = array();
$orgtimeout = $timeout;
$timeout += time(); $timeout += time();
// Putting an 'exec' before the command will not fork the command // Putting an 'exec' before the command will not fork the command
// and therefore not create any child process. proc_terminate will // and therefore not create any child process. proc_terminate will
@ -84,7 +85,7 @@ class SeedDMS_ConversionServiceExec extends SeedDMS_ConversionServiceBase {
fclose($pipes[2]); fclose($pipes[2]);
if ($timeleft <= 0) { if ($timeleft <= 0) {
proc_terminate($process); proc_terminate($process);
throw new Exception("command timeout on: " . $cmd); throw new Exception("command timeout after ".$orgtimeout." secs on: " . $cmd);
} else { } else {
$return_value = proc_close($process); $return_value = proc_close($process);
return array('stdout'=>$output, 'stderr'=>$error, 'return'=>$return_value); return array('stdout'=>$output, 'stderr'=>$error, 'return'=>$return_value);
@ -169,6 +170,9 @@ class SeedDMS_ConversionServiceExec extends SeedDMS_ConversionServiceBase {
if($hastempfile) if($hastempfile)
unlink($tmpfile); unlink($tmpfile);
$this->success = false; $this->success = false;
if($this->logger) {
$this->logger->log('Conversion from '.$this->from.' to '.$this->to.' with cmd "'.$this->cmd.'" failed: '.$e->getMessage(), PEAR_LOG_ERR);
}
return false; return false;
} }
$end = microtime(true); $end = microtime(true);