public function run()
 {
     $this->daemons = array();
     foreach ($this->config['daemons'] as $config) {
         $config += array('argv' => array(), 'autoscale' => array());
         $daemon = new PhutilDaemonHandle($this, $config['class'], $this->argv, array('log' => $this->log, 'argv' => $config['argv'], 'load' => $this->libraries, 'autoscale' => $config['autoscale']));
         $daemon->setSilent(!$this->traceMode && !$this->verbose);
         $daemon->setTraceMemory($this->traceMemory);
         $this->addDaemon($daemon, $config);
     }
     $should_reload = false;
     while (true) {
         foreach ($this->modules as $module) {
             try {
                 if ($module->shouldReloadDaemons()) {
                     $should_reload = true;
                 }
             } catch (Exception $ex) {
                 phlog($ex);
             }
         }
         if ($should_reload) {
             $this->didReceiveReloadSignal(SIGHUP);
             $should_reload = false;
         }
         $futures = array();
         foreach ($this->getDaemonHandles() as $daemon) {
             $daemon->update();
             if ($daemon->isRunning()) {
                 $futures[] = $daemon->getFuture();
             }
             if ($daemon->isDone()) {
                 $this->removeDaemon($daemon);
             }
         }
         $this->updatePidfile();
         $this->updateAutoscale();
         if ($futures) {
             $iter = id(new FutureIterator($futures))->setUpdateInterval(1);
             foreach ($iter as $future) {
                 break;
             }
         } else {
             if ($this->inGracefulShutdown) {
                 break;
             }
             sleep(1);
         }
     }
     exit($this->err);
 }
 public function run()
 {
     $this->daemons = array();
     foreach ($this->config['daemons'] as $config) {
         $config += array('argv' => array(), 'autoscale' => array());
         $daemon = new PhutilDaemonHandle($this, $config['class'], $this->argv, array('log' => $this->log, 'argv' => $config['argv'], 'load' => $this->libraries, 'autoscale' => $config['autoscale']));
         $daemon->setSilent(!$this->traceMode && !$this->verbose);
         $daemon->setTraceMemory($this->traceMemory);
         $this->addDaemon($daemon, $config);
     }
     while (true) {
         $futures = array();
         foreach ($this->getDaemonHandles() as $daemon) {
             $daemon->update();
             if ($daemon->isRunning()) {
                 $futures[] = $daemon->getFuture();
             }
             if ($daemon->isDone()) {
                 $this->removeDaemon($daemon);
             }
         }
         $this->updatePidfile();
         $this->updateAutoscale();
         if ($futures) {
             $iter = id(new FutureIterator($futures))->setUpdateInterval(1);
             foreach ($iter as $future) {
                 break;
             }
         } else {
             if ($this->inGracefulShutdown) {
                 break;
             }
             sleep(1);
         }
     }
     exit($this->err);
 }