public function testDesturct()
 {
     $adapter = new Gearman(array('default' => array('host' => '127.0.0.1', 'port' => 4730, 'timeout' => 1)));
     $adapter->connections();
     $adapter->__destruct();
     $this->assertEquals(array(), PHPUnit_Framework_Assert::readAttribute($adapter, 'connections'));
 }
Example #2
0
 /**
  * {@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));
         }
     }
 }
Example #3
0
 /**
  * {@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));
         }
     }
 }