14

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?

Jonny C
  • 1,943
  • 3
  • 20
  • 36
m150
  • 173
  • 6

2 Answers2

1

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");
Joshua Walcher
  • 506
  • 4
  • 14
-1

Hope that will help in just single command:

$command = 'php ' . 'background_process_autoresponder.php';
$a = shell_exec(sprintf('%s > /dev/null 2>&1 &', $command));
Obsidian Age
  • 41,205
  • 10
  • 48
  • 71
  • This does not provide an answer to the question. Once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](http://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/16031606) – Toby May 05 '17 at 02:06
  • I have just register over stack flow , but my work exp is over 6 years hopefully soon i increase my reputation , Thanks for your review – Mukesh Prajapat May 05 '17 at 07:54