Skip to content

Commit

Permalink
Make GC on exit configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
tersmitten committed Aug 17, 2020
1 parent 71ad990 commit b2b7493
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Console/Command/QueueShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public function initialize() {
'defaultWorkerRetries' => 4,
'workerMaxRuntime' => 0,
'cleanupTimeout' => DAY,
'exitWhenNothingToDo' => false
'exitWhenNothingToDo' => false,
'gcOnExit' => true,
],
$conf
)
Expand Down Expand Up @@ -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());
}
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b2b7493

Please sign in to comment.