public function __construct(Process $process) { if ($process->isSuccessful()) { throw new InvalidArgumentException('Expected a failed process, but the given process was successful.'); } $error = sprintf('The command "%s" failed.', $process->getInput()); if (!$process->isOutputDisabled()) { $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", $process->getOutput(), $process->getErrorOutput()); } parent::__construct($error); $this->process = $process; }
/** * @param Process $process */ public function runProcess(Process $process) { $commandLine = $process->getCommandLine(); $cwd = $process->getWorkingDirectory(); $input = $process->getInput(); try { $process->start(); $this->runningProcess[spl_object_hash($process)] = $process; $this->logger->info(sprintf('Запустили процес (cmd %s, cwd %s, input %s)', $commandLine, $cwd, $input)); $this->runningProcess[spl_object_hash($process)] = $process; } catch (RuntimeException $e) { $this->logger->critical(sprintf('Неудалось отсновить процес (cmd %s, cwd %s, input %s)', $commandLine, $cwd, $input)); } }