public function startProcess(Process $process, $pidFile, OutputInterface $log)
    {
        $this->processes[$pidFile] = $process;

        try {
            $process->start(function ($type, $buffer) use ($log) {
                $output = $log instanceof ConsoleOutputInterface && $type === Process::ERR
                    ? $log->getErrorOutput()
                    : $log;
                $output->write($buffer);
            });
        } catch (\Exception $e) {
            unset($this->processes[$pidFile]);
            throw $e;
        }

        $pid = $process->getPid();
        if (file_put_contents($pidFile, $pid) === false) {
            throw new \RuntimeException('Failed to write PID file: ' . $pidFile);
        }

        $log->writeln(sprintf('Process started: %s', $process->getCommandLine()));

        return $pid;
    }
public function startProcess(Process $process, $pidFile, OutputInterface $log)
    {
        $this->processes[$pidFile] = $process;

        try {
            $process->start(function ($type, $buffer) use ($log) {
                $output = $log instanceof ConsoleOutputInterface && $type === Process::ERR
                    ? $log->getErrorOutput()
                    : $log;
                $output->write($buffer);
            });
        } catch (\Exception $e) {
            unset($this->processes[$pidFile]);
            throw $e;
        }

        $pid = $process->getPid();
        if (file_put_contents($pidFile, $pid) === false) {
            throw new \RuntimeException('Failed to write PID file: ' . $pidFile);
        }

        $log->writeln(sprintf('Process started: %s', $process->getCommandLine()));

        return $pid;
    }
public function startProcess ( Process $ process , $ pidFile , OutputInterface $ log ) { $ this -> processes [ $ pidFile ] = $ process ; try { $ process -> start ( function ( $ type , $ buffer ) use ( $ log ) { $ output = $ log instanceof ConsoleOutputInterface && $ type === Process :: ERR ? $ log -> getErrorOutput ( ) : $ log ; $ output -> write ( $ buffer ) ; } ) ; } catch ( \ Exception $ e ) { unset ( $ this -> processes [ $ pidFile ] ) ; throw $ e ; } $ pid = $ process -> getPid ( ) ; if ( file_put_contents ( $ pidFile , $ pid ) === false ) { throw new \ RuntimeException ( 'Failed to write PID file: ' . $ pidFile ) ; } $ log -> writeln ( sprintf ( 'Process started: %s' , $ process -> getCommandLine ( ) ) ) ; return $ pid ; }
Start a managed external process.

@param Process $process
The Symfony Process object to manage.
@param string $pidFile
The path to a lock file which governs the process: if the file is
deleted then the process will be stopped in self::monitor().
@param OutputInterface $log
An output stream to which log messages can be written.

@throws \Exception on failure

@return int
The process PID.
Start a managed external process .