public function useDefaultStopSignalHandler(int $stopDelay = 10, array $signals = [\SIGINT, \SIGTERM]): self
    {
        $stopDelay = 0 >= $stopDelay ? 1 : $stopDelay;

        /**
         * @noinspection PhpUnhandledExceptionInspection
         *
         * @var LoggerInterface $logger
         */
        $logger = $this->getKernelContainerService('service_bus.logger');

        $handler = function(string $watcherId, int $signalId) use ($stopDelay, $logger): void
        {
            $logger->info(
                'A signal "{signalId}" was received',
                [
                    'signalId'  => $signalId,
                    'watcherId' => $watcherId,
                ]
            );

            $this->entryPoint->stop($stopDelay);
        };

        foreach ($signals as $signal)
        {
            /** @psalm-suppress MixedTypeCoercion Incorrect amphp types */
            Loop::onSignal($signal, $handler);
        }

        return $this;
    }
public function useDefaultStopSignalHandler(int $stopDelay = 10, array $signals = [\SIGINT, \SIGTERM]): self
    {
        $stopDelay = 0 >= $stopDelay ? 1 : $stopDelay;

        /**
         * @noinspection PhpUnhandledExceptionInspection
         *
         * @var LoggerInterface $logger
         */
        $logger = $this->getKernelContainerService('service_bus.logger');

        $handler = function(string $watcherId, int $signalId) use ($stopDelay, $logger): void
        {
            $logger->info(
                'A signal "{signalId}" was received',
                [
                    'signalId'  => $signalId,
                    'watcherId' => $watcherId,
                ]
            );

            $this->entryPoint->stop($stopDelay);
        };

        foreach ($signals as $signal)
        {
            /** @psalm-suppress MixedTypeCoercion Incorrect amphp types */
            Loop::onSignal($signal, $handler);
        }

        return $this;
    }
public function useDefaultStopSignalHandler ( int $ stopDelay = 10 , array $ signals = [ \ SIGINT , \ SIGTERM ] ) : self { $ stopDelay = 0 >= $ stopDelay ? 1 : $ stopDelay ; /**
         * @noinspection PhpUnhandledExceptionInspection
         *
         * @var LoggerInterface $logger
         */ $ logger = $ this -> getKernelContainerService ( 'service_bus.logger' ) ; $ handler = function ( string $ watcherId , int $ signalId ) use ( $ stopDelay , $ logger ) : void { $ logger -> info ( 'A signal "{signalId}" was received' , [ 'signalId' => $ signalId , 'watcherId' => $ watcherId , ] ) ; $ this -> entryPoint -> stop ( $ stopDelay ) ; } ; foreach ( $ signals as $ signal ) { /** @psalm-suppress MixedTypeCoercion Incorrect amphp types */ Loop :: onSignal ( $ signal , $ handler ) ; } return $ this ; }
Use default handler for signal "SIGINT" and "SIGTERM".

@noinspection PhpDocMissingThrowsInspection

@psalm-param  array<mixed, int> $signals

@param int   $stopDelay The delay before the completion (in seconds)
@param int[] $signals   Processed signals

@throws \Amp\Loop\UnsupportedFeatureException This might happen if ext-pcntl is missing and the loop driver doesn't
support another way to dispatch signals

@return $this
Use default handler for signal SIGINT and SIGTERM .