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:
$ 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);
}
}
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 (*
).