diff --git a/Exception/ProcessException.php b/Exception/ProcessException.php new file mode 100644 index 0000000..57454db --- /dev/null +++ b/Exception/ProcessException.php @@ -0,0 +1,18 @@ +getExitCodeText(), $process->getExitCode()); + } +} diff --git a/Services/Supervisor.php b/Services/Supervisor.php index de2dd02..da05a1a 100644 --- a/Services/Supervisor.php +++ b/Services/Supervisor.php @@ -2,6 +2,7 @@ namespace Phobetor\RabbitMqSupervisorBundle\Services; +use Phobetor\RabbitMqSupervisorBundle\Exception\ProcessException; use Symfony\Component\Process\Process; class Supervisor @@ -35,6 +36,10 @@ public function execute($cmd) $p->setWorkingDirectory($this->applicationDirectory); $p->run(); $p->wait(); + if ($p->getExitCode() !== 0) { + throw new ProcessException($p); + } + return $p; } @@ -63,6 +68,9 @@ public function run() ); $p->setWorkingDirectory($this->applicationDirectory); $p->run(); + if ($p->getExitCode() !== 0) { + throw new ProcessException($p); + } } } }