Closed yccheok closed 8 years ago
So you want to stop the worker as soon as a failed job comes through...
You're right that every part of the job itself, including most of its hooks, is executed in its own forked process (see HOWITWORKS.md to see exactly where this split happens, and what is affected). To stop the worker, you'd need to send it a signal that it should either stop work or shut down. There's a section in the README on the signals a worker listens to.
Alternately, you could requeue the failed job to a different queue that the worker isn't listening on, then move it back over manually when it's ready to actually be run.
Thanks. The following code works fine so far
$pid = getmypid();
\Resque_Event::listen('onFailure', function ($exception, $job) use (&$pid) {
...
posix_kill($pid, SIGQUIT);
});
I wish to kill the entire script which picks up the queue item, when
onFailure
happen.I tried.
I believe
onFailure
is run under different process (or thread?!)What is the proper way to prevent resque from picking up the item, just after I requeue the item?