Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php-resque job perform function not executed?

I'm trying to make a background job with php-resque. I have this code:

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

and in Mail class i have this

class Mail
{

   public function perform()
    {
            lakdf;  
    }
}

The mistake on "lakdf;" is here on purpose.

When I turn on monitor on my redis and try to execute job it write this:

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"

So from the "reque:stat:processed" I think, that my job was processed, but there is a mistake in perform function and its not writing any error, like the perform function is never executed.

Even if I make some insert to database in perform function it will do nothing.

Does anybody know, where is problem? Why it seems that perform function is not executed?

like image 340
m150 Avatar asked Dec 17 '13 12:12

m150


1 Answers

PHP will assume that

    lakdf;

is:

$lakdf;

So if you really want an error to be thrown then you can force one by replacing that line with:

error_log("I am throwing an error from within the Mail::perform function");
like image 92
Joshua Walcher Avatar answered Oct 10 '22 23:10

Joshua Walcher