diff --git a/Console/Command/QueueShell.php b/Console/Command/QueueShell.php index e777059..c8cdfab 100644 --- a/Console/Command/QueueShell.php +++ b/Console/Command/QueueShell.php @@ -82,7 +82,8 @@ public function initialize() { 'defaultWorkerRetries' => 4, 'workerMaxRuntime' => 0, 'cleanupTimeout' => DAY, - 'exitWhenNothingToDo' => false + 'exitWhenNothingToDo' => false, + 'gcOnExit' => true, ], $conf ) @@ -273,7 +274,7 @@ public function runworker() { )); } - if (rand(0, 100) > (100 - Configure::read('Queue.gcprop'))) { + if (($this->_exit && Configure::read('Queue.gcOnExit')) || rand(0, 100) > (100 - Configure::read('Queue.gcprop'))) { $this->out(__d('queue', 'Performing old job cleanup.')); $this->QueuedTask->cleanOldJobs($this->_getTaskConf()); } diff --git a/README.md b/README.md index 6298947..ff86c7f 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Configure::write('Queue.defaultWorkerRetries', 4); Configure::write('Queue.workerMaxRuntime', 0); Configure::write('Queue.cleanupTimeout', DAY); Configure::write('Queue.exitWhenNothingToDo', false); +Configure::write('Queue.gcOnExit', true); ``` Load schema: