Skip to content

Commit

Permalink
add option to trigger an oncompletion handler if available, once the …
Browse files Browse the repository at this point in the history
…job is completed
  • Loading branch information
frets1700 committed Sep 9, 2024
1 parent 42c6a5b commit 8d8240a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/Resque/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,16 @@ public function work($interval = Resque::DEFAULT_INTERVAL, $blocking = false)
pcntl_signal_dispatch();
sleep(1);
}
$exitStatus = 0;

if (pcntl_wifexited($status) === true) {
// Job is completed, trigger completion listeners
$jobArgs = $job->getArguments();
if (!empty($jobArgs['onCompletionHandler'])) {
Resque_Event::trigger('onCompletion', array(
'job' => $job,
));
}

$exitStatus = pcntl_wexitstatus($status);
if($exitStatus !== 0) {
$job->fail(new Resque_Job_DirtyExitException(
Expand Down

0 comments on commit 8d8240a

Please sign in to comment.