mirror of
https://github.com/idanoo/php-resque
synced 2025-07-01 05:32:20 +00:00
Add a plugin/event/hook system
This commit is contained in:
parent
4d4a5ffc89
commit
6f43fcfed8
10 changed files with 431 additions and 20 deletions
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
require_once dirname(__FILE__) . '/Stat.php';
|
||||
require_once dirname(__FILE__) . '/Event.php';
|
||||
require_once dirname(__FILE__) . '/Job.php';
|
||||
require_once dirname(__FILE__) . '/Job/DirtyExitException.php';
|
||||
|
||||
|
@ -180,11 +181,12 @@ class Resque_Worker
|
|||
else {
|
||||
$this->updateProcLine('Waiting for ' . implode(',', $this->queues));
|
||||
}
|
||||
usleep($interval*1000000);
|
||||
usleep($interval * 1000000);
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->log('got ' . $job);
|
||||
Resque_Event::trigger('beforeFork', $job);
|
||||
$this->workingOn($job);
|
||||
|
||||
$this->child = $this->fork();
|
||||
|
@ -231,6 +233,7 @@ class Resque_Worker
|
|||
public function perform(Resque_Job $job)
|
||||
{
|
||||
try {
|
||||
Resque_Event::trigger('afterFork', $job);
|
||||
$job->perform();
|
||||
}
|
||||
catch(Exception $e) {
|
||||
|
@ -314,6 +317,7 @@ class Resque_Worker
|
|||
{
|
||||
$this->registerSigHandlers();
|
||||
$this->pruneDeadWorkers();
|
||||
Resque_Event::trigger('beforeFirstFork');
|
||||
$this->registerWorker();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue