public function stopWhenFilesChange(string $directoryPath, int $checkInterval = 30, int $stopDelay = 5): self
    {
        $checkInterval = 0 >= $checkInterval ? 1 : $checkInterval;
        $watcher       = new FileChangesWatcher($directoryPath);

        /** @psalm-suppress MixedTypeCoercion Incorrect amphp types */
        Loop::repeat(
            $checkInterval * 1000,
            function() use ($watcher, $stopDelay): \Generator
            {
                /** @var bool $changed */
                $changed = yield $watcher->compare();

                if (true === $changed)
                {
                    /** @var LoggerInterface $logger */
                    $logger = $this->getKernelContainerService('service_bus.logger');

                    $logger->info(
                        'Application files have been changed. Shut down after {delay} seconds',
                        ['delay' => $stopDelay]
                    );

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

        return $this;
    }
public function stopWhenFilesChange(string $directoryPath, int $checkInterval = 30, int $stopDelay = 5): self
    {
        $checkInterval = 0 >= $checkInterval ? 1 : $checkInterval;
        $watcher       = new FileChangesWatcher($directoryPath);

        /** @psalm-suppress MixedTypeCoercion Incorrect amphp types */
        Loop::repeat(
            $checkInterval * 1000,
            function() use ($watcher, $stopDelay): \Generator
            {
                /** @var bool $changed */
                $changed = yield $watcher->compare();

                if (true === $changed)
                {
                    /** @var LoggerInterface $logger */
                    $logger = $this->getKernelContainerService('service_bus.logger');

                    $logger->info(
                        'Application files have been changed. Shut down after {delay} seconds',
                        ['delay' => $stopDelay]
                    );

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

        return $this;
    }
public function stopWhenFilesChange ( string $ directoryPath , int $ checkInterval = 30 , int $ stopDelay = 5 ) : self { $ checkInterval = 0 >= $ checkInterval ? 1 : $ checkInterval ; $ watcher = new FileChangesWatcher ( $ directoryPath ) ; /** @psalm-suppress MixedTypeCoercion Incorrect amphp types */ Loop :: repeat ( $ checkInterval * 1000 , function ( ) use ( $ watcher , $ stopDelay ) : \ Generator { /** @var bool $changed */ $ changed = yield $ watcher -> compare ( ) ; if ( true === $ changed ) { /** @var LoggerInterface $logger */ $ logger = $ this -> getKernelContainerService ( 'service_bus.logger' ) ; $ logger -> info ( 'Application files have been changed. Shut down after {delay} seconds' , [ 'delay' => $ stopDelay ] ) ; $ this -> entryPoint -> stop ( $ stopDelay ) ; } } ) ; return $ this ; }
Enable file change monitoring. If the application files have been modified, quit.

@param string $directoryPath
@param int    $checkInterval Hash check interval (in seconds)
@param int    $stopDelay     The delay before the completion (in seconds)

@return self
Enable file change monitoring . If the application files have been modified quit .