简体   繁体   English

PHP-Resque将无法运行perform()

[英]PHP-Resque won't run perform()

I am using PHP-Resque and can't get the perform() method to work. 我正在使用PHP-Resque ,并且无法使perform()方法正常工作。 Can anyone tell what I'm missing? 谁能告诉我我所缺少的吗?

This is my setup: 这是我的设置:

  • I have 3 terminals open running the following: 我有3个终端打开运行以下命令:
  • $ php workers.php
  • $ redis-cli monitor
  • $ php create.php (To create a job) $ php create.php (创建工作)

  • workers.php 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 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和Status为1。例如:

JobId: 757335754aec172166e8679cc3bfef58
Status: 1

I always get a Redis log that its been inserted. 我总是得到一个已插入的Redis日志。 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: 但是它似乎根本没有运行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);
    }
}

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. 第二部分是启动resque的命令,您正在执行不同的操作。 As it stands, it's looking for a queue * php bin/resque instead of all queues ( * ). 就目前而言,它正在寻找一个队列* php bin/resque而不是所有队列( * )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM