I am having trouble handling gearman worker, fatal error. Gearman daemon stops on php fatal error.
I found on this url http://www.vancelucas.com/blog/handling-exceptions-in-gearman-tasks-even-background-ones/ solution but it is not working for me. This is my gearman worker cod:
$task = "send_lead";
$gmw->addFunction("sending_lead", function() use($task) {
try {
$result = call_user_func_array($task, func_get_args());
} catch(\Exception $e) {
$result = GEARMAN_WORK_EXCEPTION;
echo "Gearman: CAUGHT EXCEPTION: " . $e->getMessage();
// Send exception to Exceptional so it can be logged with details
Exceptional::handle_exception($e, FALSE);
}
return $result;
});
while(1)
$gmw->work();
function send_lead($job)
{
$send_lead = new Frontend_Model_Index();
$send_lead->lead(json_decode($job->workload()));
}
Btw I am using zend 1.1.
Update
Error is PHP Fatal error: Call to a member function getSource_state() on a non-object in.
And that is ok error. But how to handle that error. I do not want deamon to be terminated becasue of any error, fatal or not.