Worker.php
public function start(int $maxRuntimeInSec = 60 * 15): void
    {
        \pcntl_signal(SIGTERM, function () {
            $this->shouldTerminate = true;
            $this->logger->debug('Caught SIGTERM, worker goes into termination.');
        });

        $this->startedTime = \time();

        $this->logger->info('Worker started: ' . $this->name);

        while (!$this->shouldTerminate || 0 < \count($this->runningJobs)) {
            \pcntl_signal_dispatch();

            $this->checkRunningJobs();

            if (!$this->shouldTerminate) {
                if (\count($this->runningJobs) < $this->maxJobs && null !== $job = $this->queue->dequeue()) {
                    $this->handleDequeuedJob($job);
                }

                if (\time() > $this->startedTime + $maxRuntimeInSec) {
                    $this->shouldTerminate = true;
                    $this->logger->debug('Elapsed maximum runtime, worker goes into termination.');
                }
            }

            \usleep(500000);
        }
    }
public function start(int $maxRuntimeInSec = 60 * 15): void
    {
        \pcntl_signal(SIGTERM, function () {
            $this->shouldTerminate = true;
            $this->logger->debug('Caught SIGTERM, worker goes into termination.');
        });

        $this->startedTime = \time();

        $this->logger->info('Worker started: ' . $this->name);

        while (!$this->shouldTerminate || 0 < \count($this->runningJobs)) {
            \pcntl_signal_dispatch();

            $this->checkRunningJobs();

            if (!$this->shouldTerminate) {
                if (\count($this->runningJobs) < $this->maxJobs && null !== $job = $this->queue->dequeue()) {
                    $this->handleDequeuedJob($job);
                }

                if (\time() > $this->startedTime + $maxRuntimeInSec) {
                    $this->shouldTerminate = true;
                    $this->logger->debug('Elapsed maximum runtime, worker goes into termination.');
                }
            }

            \usleep(500000);
        }
    }
public function start ( int $ maxRuntimeInSec = 60 * 15 ) : void { \ pcntl_signal ( SIGTERM , function ( ) { $ this -> shouldTerminate = true ; $ this -> logger -> debug ( 'Caught SIGTERM, worker goes into termination.' ) ; } ) ; $ this -> startedTime = \ time ( ) ; $ this -> logger -> info ( 'Worker started: ' . $ this -> name ) ; while ( ! $ this -> shouldTerminate || 0 < \ count ( $ this -> runningJobs ) ) { \ pcntl_signal_dispatch ( ) ; $ this -> checkRunningJobs ( ) ; if ( ! $ this -> shouldTerminate ) { if ( \ count ( $ this -> runningJobs ) < $ this -> maxJobs && null !== $ job = $ this -> queue -> dequeue ( ) ) { $ this -> handleDequeuedJob ( $ job ) ; } if ( \ time ( ) > $ this -> startedTime + $ maxRuntimeInSec ) { $ this -> shouldTerminate = true ; $ this -> logger -> debug ( 'Elapsed maximum runtime, worker goes into termination.' ) ; } } \ usleep ( 500000 ) ; } }
Starts polling to run jobs.

@param int $maxRuntimeInSec The maximum runtime in second, the polling will be terminated after this time was elapsed.
Starts polling to run jobs .