php resque作业执行函数未执行


php-resque job perform function not executed?

我正试图用php-resque做一个后台工作。我有这个代码:

'Resque::setBackend('127.0.0.1:6379');
'Resque::enqueue('default', ''BaseModule'Jobs'Mail',  array());

在邮件课上,我有这个

class Mail
{
   public function perform()
    {
            lakdf;  
    }
}

"lakdf;"上的错误是故意出现的。

当我打开我的redis上的监视器并尝试执行作业时,它写着:

1387283121.312817 [0 127.0.0.1:32827] "set" "resque:worker:michal-pc:9622:default" "{'"queue'":'"default'",'"run_at'":'"Tue Dec 17 12:25:21 UTC 2013'",'"payload'":{'"class'":'"''''BaseModule''''Jobs''''Mail'",'"args'":[[]],'"id'":'"c7c64e218bc951018c2a264eaf5a4b9a'"}}"
1387283121.313312 [0 127.0.0.1:32827] "incrby" "resque:stat:processed" "1"

因此,从"reque:stat:processed"我认为,我的工作已经处理好了,但perform函数中有一个错误,它没有写入任何错误,就像perform函数从未执行过一样。

即使我在执行函数时对数据库进行了一些插入,它也不会起任何作用。

有人知道问题出在哪里吗?为什么执行功能似乎没有执行?

PHP将假设

    lakdf;

是:

$lakdf;

因此,如果你真的想抛出一个错误,那么你可以通过将该行替换为:来强制抛出一个

error_log("I am throwing an error from within the Mail::perform function");

希望这将在一个命令中有所帮助:

$command = 'php ' . 'background_process_autoresponder.php';
$a = shell_exec(sprintf('%s > /dev/null 2>&1 &', $command));