src/ProcessManager.php
public function shutdown($graceful = true)
    {
        if ($this->status === self::STATE_SHUTDOWN) {
            return;
        }

        $this->output->writeln("<info>Server is shutting down.</info>");
        $this->status = self::STATE_SHUTDOWN;

        $remainingSlaves = count($this->slaves->getByStatus(Slave::READY));

        if ($remainingSlaves === 0) {
            // if for some reason there are no workers, the close callback won't do anything, so just quit.
            $this->quit();
        } else {
            $this->closeSlaves($graceful, function ($slave) use (&$remainingSlaves) {
                $this->terminateSlave($slave);
                $remainingSlaves--;

                if ($this->output->isVeryVerbose()) {
                    $this->output->writeln(
                        sprintf(
                            'Worker #%d terminated, %d more worker(s) to close.',
                            $slave->getPort(),
                            $remainingSlaves
                        )
                    );
                }

                if ($remainingSlaves === 0) {
                    $this->quit();
                }
            });
        }
    }
public function shutdown($graceful = true)
    {
        if ($this->status === self::STATE_SHUTDOWN) {
            return;
        }

        $this->output->writeln("<info>Server is shutting down.</info>");
        $this->status = self::STATE_SHUTDOWN;

        $remainingSlaves = count($this->slaves->getByStatus(Slave::READY));

        if ($remainingSlaves === 0) {
            // if for some reason there are no workers, the close callback won't do anything, so just quit.
            $this->quit();
        } else {
            $this->closeSlaves($graceful, function ($slave) use (&$remainingSlaves) {
                $this->terminateSlave($slave);
                $remainingSlaves--;

                if ($this->output->isVeryVerbose()) {
                    $this->output->writeln(
                        sprintf(
                            'Worker #%d terminated, %d more worker(s) to close.',
                            $slave->getPort(),
                            $remainingSlaves
                        )
                    );
                }

                if ($remainingSlaves === 0) {
                    $this->quit();
                }
            });
        }
    }
public function shutdown ( $ graceful = true ) { if ( $ this -> status === self :: STATE_SHUTDOWN ) { return ; } $ this -> output -> writeln ( "<info>Server is shutting down.</info>" ) ; $ this -> status = self :: STATE_SHUTDOWN ; $ remainingSlaves = count ( $ this -> slaves -> getByStatus ( Slave :: READY ) ) ; if ( $ remainingSlaves === 0 ) { // if for some reason there are no workers, the close callback won't do anything, so just quit. $ this -> quit ( ) ; } else { $ this -> closeSlaves ( $ graceful , function ( $ slave ) use ( & $ remainingSlaves ) { $ this -> terminateSlave ( $ slave ) ; $ remainingSlaves -- ; if ( $ this -> output -> isVeryVerbose ( ) ) { $ this -> output -> writeln ( sprintf ( 'Worker #%d terminated, %d more worker(s) to close.' , $ slave -> getPort ( ) , $ remainingSlaves ) ) ; } if ( $ remainingSlaves === 0 ) { $ this -> quit ( ) ; } } ) ; } }
Handles termination signals, so we can gracefully stop all servers.

@param bool $graceful If true, will wait for busy workers to finish.
Handles termination signals so we can gracefully stop all servers .