Resque_Worker::shutdown PHP Method

shutdown() public method

Schedule a worker for shutdown. Will finish processing the current job and when the timeout interval is reached, the worker will shut down.
public shutdown ( )
    public function shutdown()
    {
        $this->shutdown = true;
        $this->logger->log(Psr\Log\LogLevel::NOTICE, 'Shutting down');
    }

Usage Example

 /**
  * @test
  */
 public function it_sends_remove_file_command_to_file_remover_via_php_resque()
 {
     $this->assertTrue(file_exists($this->testFile));
     $commandBus = new CommandBus();
     $commandRouter = new CommandRouter();
     $messageDispatcher = new MessageDispatcher(['track_job_status' => true, 'queue' => 'php-resque-test-queue']);
     $commandRouter->route('Prooph\\ServiceBusTest\\Mock\\RemoveFileCommand')->to($messageDispatcher);
     $commandBus->utilize($commandRouter);
     $commandBus->utilize(new ForwardToRemoteMessageDispatcherStrategy(new ProophDomainMessageToRemoteMessageTranslator()));
     $jobId = null;
     $messageDispatcher->events()->attach('dispatch.post', function (EventInterface $e) use(&$jobId) {
         $jobId = $e->getParam('jobId');
     });
     $removeFile = RemoveFileCommand::fromPayload($this->testFile);
     $commandBus->dispatch($removeFile);
     $this->assertNotNull($jobId);
     $status = new \Resque_Job_Status($jobId);
     $this->assertEquals(\Resque_Job_Status::STATUS_WAITING, $status->get());
     $worker = new \Resque_Worker(array('php-resque-test-queue'));
     $worker->logLevel = 1;
     $worker->work(0);
     $worker->shutdown();
     $this->assertEquals(\Resque_Job_Status::STATUS_COMPLETE, $status->get());
     $this->assertFalse(file_exists($this->testFile));
 }
All Usage Examples Of Resque_Worker::shutdown