public function run($blocking = false): int
    {
        $logHandler = new StreamHandler(new ResourceOutputStream(\STDOUT));
        $logHandler->setFormatter(new ConsoleFormatter);
        $logger = new Logger('server');
        $logger->pushHandler($logHandler);

        $pid        = null;
        $lambdaLoop = function () use ($blocking, $logger, &$pid) {
            $logger->debug("Process command: {$this->process->getCommand()}");

            $this->process->start();

            $this->process->getStdout()->read()->onResolve(function (\Throwable $reason = null, $value) {
                $this->output .= $value;
            });

            $this->process->getStderr()->read()->onResolve(function (\Throwable $reason = null, $value) {
                $this->stderr .= $value;
            });

            if ($blocking) {
                $exitCode = yield $this->process->join();
                $this->setExitCode($exitCode);
                $logger->debug("Exit code: {$this->getExitCode()}");
            }

            $pid = yield $this->process->getPid();

            if ($blocking) {
                if ($this->getExitCode() !== 0) {
                    throw new \Exception("PactPHP Process returned non-zero exit code: {$this->getExitCode()}");
                }
            }

            Loop::stop();
        };

        Loop::run($lambdaLoop);

        return $pid;
    }