src/Controller/TaskRunnerController.php
private function spawn(Task $task)
    {
        $config      = $this->getTensideConfig();
        $home        = $this->getTensideHome();
        $commandline = PhpProcessSpawner::create($config, $home)->spawn(
            [
                $this->get('tenside.cli_script')->cliExecutable(),
                'tenside:runtask',
                $task->getId(),
                '-v',
                '--no-interaction'
            ]
        );

        $this->get('logger')->debug('SPAWN CLI: ' . $commandline->getCommandLine());
        $commandline->setTimeout(0);
        $commandline->start();
        if (!$commandline->isRunning()) {
            // We might end up here when the process has been forked.
            // If exit code is neither 0 nor null, we have a problem here.
            if ($exitCode = $commandline->getExitCode()) {
                /** @var LoggerInterface $logger */
                $logger = $this->get('logger');
                $logger->error('Failed to execute "' . $commandline->getCommandLine() . '"');
                $logger->error('Exit code: ' . $commandline->getExitCode());
                $logger->error('Output: ' . $commandline->getOutput());
                $logger->error('Error output: ' . $commandline->getErrorOutput());
                throw new \RuntimeException(
                    sprintf(
                        'Spawning process task %s resulted in exit code %s',
                        $task->getId(),
                        $exitCode
                    )
                );
            }
        }

        $commandline->wait();
    }
private function spawn(Task $task)
    {
        $config      = $this->getTensideConfig();
        $home        = $this->getTensideHome();
        $commandline = PhpProcessSpawner::create($config, $home)->spawn(
            [
                $this->get('tenside.cli_script')->cliExecutable(),
                'tenside:runtask',
                $task->getId(),
                '-v',
                '--no-interaction'
            ]
        );

        $this->get('logger')->debug('SPAWN CLI: ' . $commandline->getCommandLine());
        $commandline->setTimeout(0);
        $commandline->start();
        if (!$commandline->isRunning()) {
            // We might end up here when the process has been forked.
            // If exit code is neither 0 nor null, we have a problem here.
            if ($exitCode = $commandline->getExitCode()) {
                /** @var LoggerInterface $logger */
                $logger = $this->get('logger');
                $logger->error('Failed to execute "' . $commandline->getCommandLine() . '"');
                $logger->error('Exit code: ' . $commandline->getExitCode());
                $logger->error('Output: ' . $commandline->getOutput());
                $logger->error('Error output: ' . $commandline->getErrorOutput());
                throw new \RuntimeException(
                    sprintf(
                        'Spawning process task %s resulted in exit code %s',
                        $task->getId(),
                        $exitCode
                    )
                );
            }
        }

        $commandline->wait();
    }
private function spawn ( Task $ task ) { $ config = $ this -> getTensideConfig ( ) ; $ home = $ this -> getTensideHome ( ) ; $ commandline = PhpProcessSpawner :: create ( $ config , $ home ) -> spawn ( [ $ this -> get ( 'tenside.cli_script' ) -> cliExecutable ( ) , 'tenside:runtask' , $ task -> getId ( ) , '-v' , '--no-interaction' ] ) ; $ this -> get ( 'logger' ) -> debug ( 'SPAWN CLI: ' . $ commandline -> getCommandLine ( ) ) ; $ commandline -> setTimeout ( 0 ) ; $ commandline -> start ( ) ; if ( ! $ commandline -> isRunning ( ) ) { // We might end up here when the process has been forked. // If exit code is neither 0 nor null, we have a problem here. if ( $ exitCode = $ commandline -> getExitCode ( ) ) { /** @var LoggerInterface $logger */ $ logger = $ this -> get ( 'logger' ) ; $ logger -> error ( 'Failed to execute "' . $ commandline -> getCommandLine ( ) . '"' ) ; $ logger -> error ( 'Exit code: ' . $ commandline -> getExitCode ( ) ) ; $ logger -> error ( 'Output: ' . $ commandline -> getOutput ( ) ) ; $ logger -> error ( 'Error output: ' . $ commandline -> getErrorOutput ( ) ) ; throw new \ RuntimeException ( sprintf ( 'Spawning process task %s resulted in exit code %s' , $ task -> getId ( ) , $ exitCode ) ) ; } } $ commandline -> wait ( ) ; }
Spawn a detached process for a task.

@param Task $task The task to spawn a process for.

@return void

@throws \RuntimeException When the task could not be started.
Spawn a detached process for a task .