[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/infrastructure/daemon/workers/ -> PhabricatorTaskmasterDaemon.php (source)

   1  <?php
   2  
   3  final class PhabricatorTaskmasterDaemon extends PhabricatorDaemon {
   4  
   5    public function run() {
   6      $sleep = 0;
   7      do {
   8        $tasks = id(new PhabricatorWorkerLeaseQuery())
   9          ->setLimit(1)
  10          ->execute();
  11  
  12        if ($tasks) {
  13          foreach ($tasks as $task) {
  14            $id = $task->getID();
  15            $class = $task->getTaskClass();
  16  
  17            $this->log("Working on task {$id} ({$class})...");
  18  
  19            $task = $task->executeTask();
  20            $ex = $task->getExecutionException();
  21            if ($ex) {
  22              if ($ex instanceof PhabricatorWorkerPermanentFailureException) {
  23                $this->log("Task {$id} failed permanently.");
  24              } else if ($ex instanceof PhabricatorWorkerYieldException) {
  25                $this->log(pht('Task %s yielded.', $id));
  26              } else {
  27                $this->log("Task {$id} failed!");
  28                throw new PhutilProxyException(
  29                  "Error while executing task ID {$id} from queue.",
  30                  $ex);
  31              }
  32            } else {
  33              $this->log("Task {$id} complete! Moved to archive.");
  34            }
  35          }
  36  
  37          $sleep = 0;
  38        } else {
  39          $sleep = min($sleep + 1, 30);
  40        }
  41  
  42        $this->sleep($sleep);
  43      } while (!$this->shouldExit());
  44    }
  45  
  46  }


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