diff --git a/vendors/shells/queue.php b/vendors/shells/queue.php index c954d17..56f6fb8 100644 --- a/vendors/shells/queue.php +++ b/vendors/shells/queue.php @@ -1,4 +1,5 @@ exit = false; $starttime = time(); $group = null; if (isset($this->params['group']) && !empty($this->params['group'])) { $group = $this->params['group']; } - while (!$exit) { + while (!$this->exit) { if($this->_verbose) { $this->out('Looking for Job....'); } $data = $this->QueuedTask->requestJob($this->getTaskConf(), $group); if ($this->QueuedTask->exit === true) { - $exit = true; + $this->exit = true; } else { if ($data !== false) { $this->out('Running Job of type "' . $data['jobtype'] . '"'); @@ -155,7 +159,7 @@ public function runworker() { } } elseif (Configure::read('queue.exitwhennothingtodo')) { $this->out('nothing to do, exiting.'); - $exit = true; + $this->exit = true; } else { if($this->_verbose) { $this->out('nothing to do, sleeping.'); @@ -165,10 +169,10 @@ public function runworker() { // check if we are over the maximum runtime and end processing if so. if (Configure::read('queue.workermaxruntime') != 0 && (time() - $starttime) >= Configure::read('queue.workermaxruntime')) { - $exit = true; + $this->exit = true; $this->out('Reached runtime of ' . (time() - $starttime) . ' Seconds (Max ' . Configure::read('queue.workermaxruntime') . '), terminating.'); } - if ($exit || rand(0, 100) > (100 - Configure::read('queue.gcprop'))) { + if ($this->exit || rand(0, 100) > (100 - Configure::read('queue.gcprop'))) { $this->out('Performing Old job cleanup.'); $this->QueuedTask->cleanOldJobs(); } @@ -255,5 +259,9 @@ function out($str='') { return parent::out($str); } + function _exit($signal) { + $this->exit = true; + } + } -?> \ No newline at end of file +?>