/**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $adapter = new GearmanTelnetMonitor($this->getGearmanServers());
     $watch = $input->getOption('watch');
     $once = true;
     while ($once || $watch) {
         $status = $adapter->status();
         foreach ($status as $server => $queues) {
             $output->writeln("<info>Status for Server {$server}</info>");
             $output->writeln("");
             if ($this->getHelperSet()->has('table')) {
                 // Symfony 2.3 console goodness
                 /** @var $table \Symfony\Component\Console\Helper\TableHelper */
                 $table = $this->getHelperSet()->get('table');
                 $table->setHeaders(array('Queue', 'Jobs', 'Workers working', 'Workers total'))->setRows($queues);
                 $table->render($output);
             } else {
                 foreach ($queues as $queue) {
                     $str = "    <comment>{$queue['name']}</comment> Jobs: {$queue['queue']}";
                     $str .= " Workers: {$queue['running']} / {$queue['workers']}";
                     $output->writeln($str);
                 }
             }
         }
         $once = false;
         if ($watch) {
             sleep(intval($watch));
         }
     }
 }
 public function testConnectWithDefaultTimeout()
 {
     $adapter = new Gearman(array('default' => array('host' => '127.0.0.1', 'port' => 4730)));
     $statuses = $adapter->status();
     $this->assertArrayHasKey('default', $statuses);
     $status = $statuses['default'];
     $this->assertContains(array('name' => 'test1', 'queue' => 0, 'running' => 0, 'workers' => 1, 'error' => false), $status);
     $this->assertContains(array('name' => 'test2', 'queue' => 0, 'running' => 0, 'workers' => 1, 'error' => false), $status);
 }
 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $adapter = new GearmanTelnetMonitor($this->getGearmanServers());
     $watch = $input->getOption('watch');
     $once = true;
     while ($once || $watch) {
         $status = $adapter->status();
         foreach ($status as $server => $queues) {
             $output->writeln("<info>Status for Server {$server}</info>");
             $output->writeln("");
             $table = new Table($output);
             $table->setHeaders(['Queue', 'Jobs', 'Workers working', 'Workers total', 'Errors'])->setRows($queues);
             $table->render($output);
         }
         $output->writeln("");
         $output->writeln("");
         $once = false;
         if ($watch) {
             sleep(intval($watch));
         }
     }
 }