我正在使用PHP-Resque并且无法让perform()方法工作。谁能告诉我我错过了什么?
这是我的设置:
- 我打开了 3 个终端,运行以下命令:
$ php workers.php
$ redis-cli monitor
$ php create.php
(创建工作)工人.php
<?php putenv("VVERBOSE=1"); putenv("LOGGING=1"); putenv("QUEUE=* php bin/resque"); require_once APPPATH . '../vendor/chrisboulton/php-resque/bin/resque';
创建.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(); }
我总是得到一个 JobId 和 1 的状态。例如:
JobId: 757335754aec172166e8679cc3bfef58
Status: 1
我总是得到一个被插入的 Redis 日志。例如:
[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"
然而它似乎根本没有运行 perform() 方法:
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);
}
}