2

I am using PHP-Resque and can't get the perform() method to work. Can anyone tell what I'm missing?

This is my setup:

  • I have 3 terminals open running the following:
  • $ php workers.php
  • $ redis-cli monitor
  • $ php create.php (To create a job)

  • workers.php

    <?php
    
    putenv("VVERBOSE=1");
    putenv("LOGGING=1");
    putenv("QUEUE=* php bin/resque"); 
    require_once APPPATH . '../vendor/chrisboulton/php-resque/bin/resque';
    
  • create.php

    <?php
    
    $jobId = Resque::enqueue('JESSE', 'Dog', ['hey'], true);
    echo "JobId: $jobId\n";
    
    $status = new Resque_Job_Status($jobId);
    if ($status->isTracking()) {
        echo "\nStatus: " . $status->get();
    }
    

I always get a JobId and Status of 1. eg:

JobId: 757335754aec172166e8679cc3bfef58
Status: 1

I always get a Redis log that its been inserted. eg:

[2 127.0.0.1:38912] "sadd" "resque:queues" "JESSE"
[2 127.0.0.1:38912] "rpush" "resque:queue:JESSE" "{\"class\":\"Dog\",\"args\":[[\"hey\"]],\"id\":\"757335754aec172166e8679cc3bfef58\"}"
[2 127.0.0.1:38912] "set" "resque:job:757335754aec172166e8679cc3bfef58:status" "{\"status\":1,\"updated\":1398269884,\"started\":1398269884}"
[2 127.0.0.1:38912] "exists" "resque:job:757335754aec172166e8679cc3bfef58:status"

Yet it doesn't seem to be running the perform() method at all:

class Dog {
    public function perform()
    {
        echo 'TEST TEST TEST TEST';

        fwrite('/tmp/resque-output.txt', 'This is running', w);
        fwrite(STDOUT, 'Start job! -> ');
        sleep(1);
        fwrite(STDOUT, 'Job ended!' . PHP_EOL);
    }
}
Brandon
  • 16,382
  • 12
  • 55
  • 88
JREAM
  • 5,741
  • 11
  • 46
  • 84
  • 1
    I have problems setting up php-resque for codeigniter app. This seems a approach for codeigniter . In case YES. How does php workers.php fits in in the context of codeigniter. – MadNik Feb 23 '15 at 05:15
  • its says "Set QUEUE env var containing the list of queues to work" when I try to run workers. – MadNik Feb 23 '15 at 05:42

1 Answers1

4

Pretty sure it's this:

putenv("QUEUE=* php bin/resque"); 

That should just be:

putenv("QUEUE=*"); 

The second part is the command to start resque, which you're doing differently. As it stands, it's looking for a queue * php bin/resque instead of all queues (*).

Brandon
  • 16,382
  • 12
  • 55
  • 88
  • Yes it worked perfectly, I was Baffled. I got confused reading 3 different tutorials I and there are a few branches that might be dated or newer. – JREAM Apr 23 '14 at 16:44
  • Yeah I've had some problems with php-resque, as the repo is significantly newer than their last stable release. – Brandon Apr 23 '14 at 16:47