public function monitor(OutputInterface $log)
    {
        while (count($this->processes)) {
            sleep(1);
            foreach ($this->processes as $pidFile => $process) {
                // The user can delete the PID file in order to stop the
                // process deliberately.
                if (!file_exists($pidFile)) {
                    $log->writeln(sprintf('Process stopped: %s', $process->getCommandLine()));
                    $process->stop();
                    unset($this->processes[$pidFile]);
                } elseif (!$process->isRunning()) {
                    // If the process has been stopped via another method, remove it
                    // from the list, and log a message.
                    $exitCode = $process->getExitCode();
                    if ($signal = $this->getSignal($exitCode)) {
                        $log->writeln(sprintf('Process stopped with signal %s: %s', $signal, $process->getCommandLine()));
                    } elseif ($exitCode > 0) {
                        $log->writeln(sprintf(
                            'Process failed with exit code %s: %s',
                            $exitCode,
                            $process->getCommandLine()
                        ));
                    } else {
                        $log->writeln(sprintf(
                            'Process stopped with exit code %s: %s',
                            $exitCode,
                            $process->getCommandLine()
                        ));
                    }
                    unlink($pidFile);
                    unset($this->processes[$pidFile]);
                }
            }
        }
    }
public function monitor(OutputInterface $log)
    {
        while (count($this->processes)) {
            sleep(1);
            foreach ($this->processes as $pidFile => $process) {
                // The user can delete the PID file in order to stop the
                // process deliberately.
                if (!file_exists($pidFile)) {
                    $log->writeln(sprintf('Process stopped: %s', $process->getCommandLine()));
                    $process->stop();
                    unset($this->processes[$pidFile]);
                } elseif (!$process->isRunning()) {
                    // If the process has been stopped via another method, remove it
                    // from the list, and log a message.
                    $exitCode = $process->getExitCode();
                    if ($signal = $this->getSignal($exitCode)) {
                        $log->writeln(sprintf('Process stopped with signal %s: %s', $signal, $process->getCommandLine()));
                    } elseif ($exitCode > 0) {
                        $log->writeln(sprintf(
                            'Process failed with exit code %s: %s',
                            $exitCode,
                            $process->getCommandLine()
                        ));
                    } else {
                        $log->writeln(sprintf(
                            'Process stopped with exit code %s: %s',
                            $exitCode,
                            $process->getCommandLine()
                        ));
                    }
                    unlink($pidFile);
                    unset($this->processes[$pidFile]);
                }
            }
        }
    }
public function monitor ( OutputInterface $ log ) { while ( count ( $ this -> processes ) ) { sleep ( 1 ) ; foreach ( $ this -> processes as $ pidFile => $ process ) { // The user can delete the PID file in order to stop the // process deliberately. if ( ! file_exists ( $ pidFile ) ) { $ log -> writeln ( sprintf ( 'Process stopped: %s' , $ process -> getCommandLine ( ) ) ) ; $ process -> stop ( ) ; unset ( $ this -> processes [ $ pidFile ] ) ; } elseif ( ! $ process -> isRunning ( ) ) { // If the process has been stopped via another method, remove it // from the list, and log a message. $ exitCode = $ process -> getExitCode ( ) ; if ( $ signal = $ this -> getSignal ( $ exitCode ) ) { $ log -> writeln ( sprintf ( 'Process stopped with signal %s: %s' , $ signal , $ process -> getCommandLine ( ) ) ) ; } elseif ( $ exitCode > 0 ) { $ log -> writeln ( sprintf ( 'Process failed with exit code %s: %s' , $ exitCode , $ process -> getCommandLine ( ) ) ) ; } else { $ log -> writeln ( sprintf ( 'Process stopped with exit code %s: %s' , $ exitCode , $ process -> getCommandLine ( ) ) ) ; } unlink ( $ pidFile ) ; unset ( $ this -> processes [ $ pidFile ] ) ; } } } }
Monitor processes and stop them if their PID file no longer exists.

@param OutputInterface $log
A log file as a Symfony Console output object.
Monitor processes and stop them if their PID file no longer exists .