[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/infrastructure/daemon/garbagecollector/ -> PhabricatorGarbageCollectorDaemon.php (source)

   1  <?php
   2  
   3  /**
   4   * Collects old logs and caches to reduce the amount of data stored in the
   5   * database.
   6   */
   7  final class PhabricatorGarbageCollectorDaemon extends PhabricatorDaemon {
   8  
   9    public function run() {
  10      $collectors = id(new PhutilSymbolLoader())
  11        ->setAncestorClass('PhabricatorGarbageCollector')
  12        ->loadObjects();
  13  
  14      do {
  15        foreach ($collectors as $name => $collector) {
  16          $more_garbage = false;
  17          do {
  18            if ($more_garbage) {
  19              $this->log(pht('Collecting more garbage with "%s".', $name));
  20            } else {
  21              $this->log(pht('Collecting garbage with "%s".', $name));
  22            }
  23  
  24            $more_garbage = $collector->collectGarbage();
  25            $this->stillWorking();
  26          } while ($more_garbage);
  27        }
  28  
  29        // We made it to the end of the run cycle of every GC, so we're more or
  30        // less caught up. Ease off the GC loop so we don't keep doing table
  31        // scans just to delete a handful of rows; wake up in a few hours.
  32        $this->log(pht('All caught up, waiting for more garbage.'));
  33        $this->sleep(4 * (60 * 60));
  34      } while (!$this->shouldExit());
  35  
  36    }
  37  
  38  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1