private function startCron(Cron $cron)
    {
        if ($this->isLocked($cron)) {
            return;
        }

        $this->output->writeln(sprintf('Started %s.', $cron));
        $this->changeState($cron, Cron::STATE_RUNNING);

        $pb = $this->getCommandProcessBuilder();
        $parts = explode(' ', $cron->getCommand());
        foreach ($parts as $part) {
            $pb->add($part);
        }

        $process = $pb->getProcess();
        $process->setTimeout(3600);

        try {
            $process->mustRun();

            $this->output->writeln(' > '.$process->getOutput());

            if (!$process->isSuccessful()) {
                $this->output->writeln(' > '.$process->getErrorOutput());
                if(strpos($process->getErrorOutput(), 'timeout') !== false) {
                    $this->changeState($cron, Cron::STATE_TERMINATED, $process->getErrorOutput());
                } else {
                    $this->changeState($cron, Cron::STATE_FAILED, $process->getErrorOutput());
                }
            } else {
                $this->changeState($cron, Cron::STATE_FINISHED);
            }
        } catch (\Exception $e) {
            $message = $e->getMessage();

            if(strpos($e->getMessage(), 'timeout') !== false) {
                $this->output->writeln(' > '.$e->getMessage());
                $this->changeState($cron, Cron::STATE_TERMINATED, $e->getMessage());
            } else {
                $this->output->writeln(' > '.$e->getMessage());
                $this->changeState($cron, Cron::STATE_FAILED, $e->getMessage());
            }
        }
    }
private function startCron(Cron $cron)
    {
        if ($this->isLocked($cron)) {
            return;
        }

        $this->output->writeln(sprintf('Started %s.', $cron));
        $this->changeState($cron, Cron::STATE_RUNNING);

        $pb = $this->getCommandProcessBuilder();
        $parts = explode(' ', $cron->getCommand());
        foreach ($parts as $part) {
            $pb->add($part);
        }

        $process = $pb->getProcess();
        $process->setTimeout(3600);

        try {
            $process->mustRun();

            $this->output->writeln(' > '.$process->getOutput());

            if (!$process->isSuccessful()) {
                $this->output->writeln(' > '.$process->getErrorOutput());
                if(strpos($process->getErrorOutput(), 'timeout') !== false) {
                    $this->changeState($cron, Cron::STATE_TERMINATED, $process->getErrorOutput());
                } else {
                    $this->changeState($cron, Cron::STATE_FAILED, $process->getErrorOutput());
                }
            } else {
                $this->changeState($cron, Cron::STATE_FINISHED);
            }
        } catch (\Exception $e) {
            $message = $e->getMessage();

            if(strpos($e->getMessage(), 'timeout') !== false) {
                $this->output->writeln(' > '.$e->getMessage());
                $this->changeState($cron, Cron::STATE_TERMINATED, $e->getMessage());
            } else {
                $this->output->writeln(' > '.$e->getMessage());
                $this->changeState($cron, Cron::STATE_FAILED, $e->getMessage());
            }
        }
    }
private function startCron ( Cron $ cron ) { if ( $ this -> isLocked ( $ cron ) ) { return ; } $ this -> output -> writeln ( sprintf ( 'Started %s.' , $ cron ) ) ; $ this -> changeState ( $ cron , Cron :: STATE_RUNNING ) ; $ pb = $ this -> getCommandProcessBuilder ( ) ; $ parts = explode ( ' ' , $ cron -> getCommand ( ) ) ; foreach ( $ parts as $ part ) { $ pb -> add ( $ part ) ; } $ process = $ pb -> getProcess ( ) ; $ process -> setTimeout ( 3600 ) ; try { $ process -> mustRun ( ) ; $ this -> output -> writeln ( ' > ' . $ process -> getOutput ( ) ) ; if ( ! $ process -> isSuccessful ( ) ) { $ this -> output -> writeln ( ' > ' . $ process -> getErrorOutput ( ) ) ; if ( strpos ( $ process -> getErrorOutput ( ) , 'timeout' ) !== false ) { $ this -> changeState ( $ cron , Cron :: STATE_TERMINATED , $ process -> getErrorOutput ( ) ) ; } else { $ this -> changeState ( $ cron , Cron :: STATE_FAILED , $ process -> getErrorOutput ( ) ) ; } } else { $ this -> changeState ( $ cron , Cron :: STATE_FINISHED ) ; } } catch ( \ Exception $ e ) { $ message = $ e -> getMessage ( ) ; if ( strpos ( $ e -> getMessage ( ) , 'timeout' ) !== false ) { $ this -> output -> writeln ( ' > ' . $ e -> getMessage ( ) ) ; $ this -> changeState ( $ cron , Cron :: STATE_TERMINATED , $ e -> getMessage ( ) ) ; } else { $ this -> output -> writeln ( ' > ' . $ e -> getMessage ( ) ) ; $ this -> changeState ( $ cron , Cron :: STATE_FAILED , $ e -> getMessage ( ) ) ; } } }
Start a cron.

@param Cron $cron
Start a cron .