protected function registerSignalHandler(WorkerInterface $worker): void
    {
        $this->logger->info('Register a signal handler that a worker should respond to');

        SignalHandler::create(
            SignalHandler::KNOWN_SIGNALS,
            function (int $signal, string $signalName) use ($worker) {
                $this->logger->info('{type}: Was received recognized signal {signal}', [
                    'type'   => $worker->getName(),
                    'signal' => $signalName,
                ]);

                switch ($signal) {
                    case SIGTERM:
                        $worker->shutDownNow();
                        break;
                    case SIGINT:
                        $worker->shutDownNow();
                        break;
                    case SIGQUIT:
                        $worker->shutdown();
                        break;
                    case SIGUSR1:
                        $worker->killChildren();
                        break;
                    case SIGUSR2:
                        $worker->pauseProcessing();
                        break;
                    case SIGCONT:
                        $worker->unPauseProcessing();
                        break;
                }
            }
        );
    }
protected function registerSignalHandler(WorkerInterface $worker): void
    {
        $this->logger->info('Register a signal handler that a worker should respond to');

        SignalHandler::create(
            SignalHandler::KNOWN_SIGNALS,
            function (int $signal, string $signalName) use ($worker) {
                $this->logger->info('{type}: Was received recognized signal {signal}', [
                    'type'   => $worker->getName(),
                    'signal' => $signalName,
                ]);

                switch ($signal) {
                    case SIGTERM:
                        $worker->shutDownNow();
                        break;
                    case SIGINT:
                        $worker->shutDownNow();
                        break;
                    case SIGQUIT:
                        $worker->shutdown();
                        break;
                    case SIGUSR1:
                        $worker->killChildren();
                        break;
                    case SIGUSR2:
                        $worker->pauseProcessing();
                        break;
                    case SIGCONT:
                        $worker->unPauseProcessing();
                        break;
                }
            }
        );
    }
protected function registerSignalHandler ( WorkerInterface $ worker ) : void { $ this -> logger -> info ( 'Register a signal handler that a worker should respond to' ) ; SignalHandler :: create ( SignalHandler :: KNOWN_SIGNALS , function ( int $ signal , string $ signalName ) use ( $ worker ) { $ this -> logger -> info ( '{type}: Was received recognized signal {signal}' , [ 'type' => $ worker -> getName ( ) , 'signal' => $ signalName , ] ) ; switch ( $ signal ) { case SIGTERM : $ worker -> shutDownNow ( ) ; break ; case SIGINT : $ worker -> shutDownNow ( ) ; break ; case SIGQUIT : $ worker -> shutdown ( ) ; break ; case SIGUSR1 : $ worker -> killChildren ( ) ; break ; case SIGUSR2 : $ worker -> pauseProcessing ( ) ; break ; case SIGCONT : $ worker -> unPauseProcessing ( ) ; break ; } } ) ; }
Register a signal handler.

TERM: Shutdown immediately and stop processing jobs (quick shutdown).
INT:  Shutdown immediately and stop processing jobs (quick shutdown).
QUIT: Shutdown after the current job finishes processing (graceful shutdown).
USR1: Kill the forked child immediately and continue processing jobs.
USR2: Pausing job processing.
CONT: Resumes worker allowing it to pick.

@link   http://man7.org/linux/man-pages/man7/signal.7.html

@param  WorkerInterface $worker
@return void
Register a signal handler .