@@ -25,19 +25,19 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | protected $interval = 5; |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var boolean True if on the next iteration, the worker should shutdown. |
|
| 30 | - */ |
|
| 31 | - private $shutdown = false; |
|
| 28 | + /** |
|
| 29 | + * @var boolean True if on the next iteration, the worker should shutdown. |
|
| 30 | + */ |
|
| 31 | + private $shutdown = false; |
|
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | - * The primary loop for a worker. |
|
| 35 | - * |
|
| 36 | - * Every $interval (seconds), the scheduled queue will be checked for jobs |
|
| 37 | - * that should be pushed to Resque. |
|
| 38 | - * |
|
| 39 | - * @param int $interval How often to check schedules. |
|
| 40 | - */ |
|
| 34 | + * The primary loop for a worker. |
|
| 35 | + * |
|
| 36 | + * Every $interval (seconds), the scheduled queue will be checked for jobs |
|
| 37 | + * that should be pushed to Resque. |
|
| 38 | + * |
|
| 39 | + * @param int $interval How often to check schedules. |
|
| 40 | + */ |
|
| 41 | 41 | public function work($interval = null) |
| 42 | 42 | { |
| 43 | 43 | if ($interval !== null) { |
@@ -47,10 +47,10 @@ discard block |
||
| 47 | 47 | $this->updateProcLine('Starting'); |
| 48 | 48 | $this->registerSigHandlers(); |
| 49 | 49 | |
| 50 | - while (true) { |
|
| 51 | - if($this->shutdown) { |
|
| 52 | - break; |
|
| 53 | - } |
|
| 50 | + while (true) { |
|
| 51 | + if($this->shutdown) { |
|
| 52 | + break; |
|
| 53 | + } |
|
| 54 | 54 | $this->handleDelayedItems(); |
| 55 | 55 | $this->sleep(); |
| 56 | 56 | } |
@@ -136,26 +136,26 @@ discard block |
||
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - /** |
|
| 140 | - * Register signal handlers that a worker should respond to. |
|
| 141 | - * |
|
| 142 | - * TERM: Shutdown immediately and stop processing jobs. |
|
| 143 | - * INT: Shutdown immediately and stop processing jobs. |
|
| 144 | - * QUIT: Shutdown after the current job finishes processing. |
|
| 145 | - */ |
|
| 146 | - private function registerSigHandlers() |
|
| 147 | - { |
|
| 148 | - if(!function_exists('pcntl_signal')) { |
|
| 149 | - return; |
|
| 150 | - } |
|
| 139 | + /** |
|
| 140 | + * Register signal handlers that a worker should respond to. |
|
| 141 | + * |
|
| 142 | + * TERM: Shutdown immediately and stop processing jobs. |
|
| 143 | + * INT: Shutdown immediately and stop processing jobs. |
|
| 144 | + * QUIT: Shutdown after the current job finishes processing. |
|
| 145 | + */ |
|
| 146 | + private function registerSigHandlers() |
|
| 147 | + { |
|
| 148 | + if(!function_exists('pcntl_signal')) { |
|
| 149 | + return; |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - pcntl_signal(SIGTERM, array($this, 'shutdown')); |
|
| 153 | - pcntl_signal(SIGINT, array($this, 'shutdown')); |
|
| 154 | - pcntl_signal(SIGQUIT, array($this, 'shutdown')); |
|
| 155 | - } |
|
| 152 | + pcntl_signal(SIGTERM, array($this, 'shutdown')); |
|
| 153 | + pcntl_signal(SIGINT, array($this, 'shutdown')); |
|
| 154 | + pcntl_signal(SIGQUIT, array($this, 'shutdown')); |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | - public function shutdown() |
|
| 158 | - { |
|
| 159 | - $this->shutdown = true; |
|
| 160 | - } |
|
| 157 | + public function shutdown() |
|
| 158 | + { |
|
| 159 | + $this->shutdown = true; |
|
| 160 | + } |
|
| 161 | 161 | } |