src/ProcessManager.php
public function run()
    {
        Debug::enable();

        // make whatever is necessary to disable all stuff that could buffer output
        ini_set('zlib.output_compression', 0);
        ini_set('output_buffering', 0);
        ini_set('implicit_flush', 1);
        ob_implicit_flush(1);

        $this->loop = Factory::create();
        $this->controller = new UnixServer($this->getControllerSocketPath(), $this->loop);
        $this->controller->on('connection', [$this, 'onSlaveConnection']);

        $this->web = new Server(sprintf('%s:%d', $this->host, $this->port), $this->loop);
        $this->web->on('connection', [$this, 'onRequest']);

        $this->loop->addSignal(SIGTERM, [$this, 'shutdown']);
        $this->loop->addSignal(SIGINT, [$this, 'shutdown']);
        $this->loop->addSignal(SIGCHLD, [$this, 'handleSigchld']);
        $this->loop->addSignal(SIGUSR1, [$this, 'restartSlaves']);
        $this->loop->addSignal(SIGUSR2, [$this, 'reloadSlaves']);

        if ($this->isDebug()) {
            $this->loop->addPeriodicTimer(0.5, function () {
                $this->checkChangedFiles();
            });
        }

        $loopClass = (new \ReflectionClass($this->loop))->getShortName();

        $this->output->writeln("<info>Starting PHP-PM with {$this->slaveCount} workers, using {$loopClass} ...</info>");
        $this->writePid();

        $this->createSlaves();

        $this->loop->run();
    }
public function run()
    {
        Debug::enable();

        // make whatever is necessary to disable all stuff that could buffer output
        ini_set('zlib.output_compression', 0);
        ini_set('output_buffering', 0);
        ini_set('implicit_flush', 1);
        ob_implicit_flush(1);

        $this->loop = Factory::create();
        $this->controller = new UnixServer($this->getControllerSocketPath(), $this->loop);
        $this->controller->on('connection', [$this, 'onSlaveConnection']);

        $this->web = new Server(sprintf('%s:%d', $this->host, $this->port), $this->loop);
        $this->web->on('connection', [$this, 'onRequest']);

        $this->loop->addSignal(SIGTERM, [$this, 'shutdown']);
        $this->loop->addSignal(SIGINT, [$this, 'shutdown']);
        $this->loop->addSignal(SIGCHLD, [$this, 'handleSigchld']);
        $this->loop->addSignal(SIGUSR1, [$this, 'restartSlaves']);
        $this->loop->addSignal(SIGUSR2, [$this, 'reloadSlaves']);

        if ($this->isDebug()) {
            $this->loop->addPeriodicTimer(0.5, function () {
                $this->checkChangedFiles();
            });
        }

        $loopClass = (new \ReflectionClass($this->loop))->getShortName();

        $this->output->writeln("<info>Starting PHP-PM with {$this->slaveCount} workers, using {$loopClass} ...</info>");
        $this->writePid();

        $this->createSlaves();

        $this->loop->run();
    }
public function run ( ) { Debug :: enable ( ) ; // make whatever is necessary to disable all stuff that could buffer output ini_set ( 'zlib.output_compression' , 0 ) ; ini_set ( 'output_buffering' , 0 ) ; ini_set ( 'implicit_flush' , 1 ) ; ob_implicit_flush ( 1 ) ; $ this -> loop = Factory :: create ( ) ; $ this -> controller = new UnixServer ( $ this -> getControllerSocketPath ( ) , $ this -> loop ) ; $ this -> controller -> on ( 'connection' , [ $ this , 'onSlaveConnection' ] ) ; $ this -> web = new Server ( sprintf ( '%s:%d' , $ this -> host , $ this -> port ) , $ this -> loop ) ; $ this -> web -> on ( 'connection' , [ $ this , 'onRequest' ] ) ; $ this -> loop -> addSignal ( SIGTERM , [ $ this , 'shutdown' ] ) ; $ this -> loop -> addSignal ( SIGINT , [ $ this , 'shutdown' ] ) ; $ this -> loop -> addSignal ( SIGCHLD , [ $ this , 'handleSigchld' ] ) ; $ this -> loop -> addSignal ( SIGUSR1 , [ $ this , 'restartSlaves' ] ) ; $ this -> loop -> addSignal ( SIGUSR2 , [ $ this , 'reloadSlaves' ] ) ; if ( $ this -> isDebug ( ) ) { $ this -> loop -> addPeriodicTimer ( 0.5 , function ( ) { $ this -> checkChangedFiles ( ) ; } ) ; } $ loopClass = ( new \ ReflectionClass ( $ this -> loop ) ) -> getShortName ( ) ; $ this -> output -> writeln ( "<info>Starting PHP-PM with {$this->slaveCount} workers, using {$loopClass} ...</info>" ) ; $ this -> writePid ( ) ; $ this -> createSlaves ( ) ; $ this -> loop -> run ( ) ; }
Starts the main loop. Blocks.
Starts the main loop . Blocks .