コード例 #1
0
 /**
  * Reads a content of log-files of specified process
  *
  * @param $row
  * @throws \Exception
  */
 public function postFinishProcess($row)
 {
     $errors = $this->parser->parseFile($row['stderr']);
     $output = $this->parser->parseFile($row['stdout']);
     $promise = $this->promiseBroker->get($row['promiseId']);
     if ($errors['fatalStatus']) {
         $promise->reject($errors['message']);
     } else {
         $promise->resolve($output['message'] . PHP_EOL . $errors['message']);
     }
 }
コード例 #2
0
ファイル: Script.php プロジェクト: avz-cmf/zaboy-scheduler
 /**
  * {@inherit}
  *
  * {@inherit}
  */
 public function call(array $options = [])
 {
     $cmd = $this->commandPrefix . ' ' . $this->script;
     $cmd .= $this->commandLineWorker->makeParamsString(['scriptOptions' => $this->commandLineWorker->encodeParams($options)]);
     // Files names for stdout and stderr
     $stdOutFilename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('stdout_', 1);
     $stdErrFilename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('stderr_', 1);
     $cmd .= "  1>{$stdOutFilename} 2>{$stdErrFilename}";
     if (substr(php_uname(), 0, 7) == "Windows") {
         pclose(popen($cmd, "r"));
     } else {
         $cmd .= " & echo \$!";
         exec($cmd, $output);
     }
     $errors = $this->parser->parseFile($stdErrFilename);
     $output = $this->parser->parseFile($stdOutFilename);
     if ($errors['fatalStatus']) {
         throw new CallbackException($errors['message']);
     }
     return $output['message'];
 }