protected function execute(InputInterface $input, OutputInterface $output)
 {
     $systemCheck = new SystemCheck();
     $systemCheck->checkRedisIsInstalled();
     $settings = Queue\Factory::getSettings();
     if ($settings->queueEnabled->getValue()) {
         $output->writeln('Queue is enabled');
     } else {
         $output->writeln('<comment>' . strtoupper('Queue is disabled: ') . 'No new requests will be written into the queue, processing the remaining requests is still possible.</comment>');
     }
     $backend = Queue\Factory::makeBackend();
     $manager = Queue\Factory::makeQueueManager($backend);
     $queues = $manager->getAllQueues();
     $lock = Queue\Factory::makeLock($backend);
     if ($settings->processDuringTrackingRequest->getValue()) {
         $output->writeln('Request sets in the queue will be processed automatically after a tracking request');
     } else {
         $output->writeln('The command <comment>./console queuedtracking:process</comment> has to be executed to process request sets within queue');
     }
     $output->writeln(sprintf('Up to %d workers will be used', $manager->getNumberOfAvailableQueues()));
     $output->writeln(sprintf('Processor will start once there are at least %s request sets in the queue', $manager->getNumberOfRequestsToProcessAtSameTime()));
     while (1) {
         $memory = $backend->getMemoryStats();
         // I know this will only work with redis currently as it is not defined in backend interface etc. needs to be refactored once we add another backend
         $numInQueue = array();
         foreach ($queues as $queue) {
             $numInQueue[] = $queue->getNumberOfRequestSetsInQueue();
         }
         $message = sprintf('%s (%s) request sets left in queue. %s used memory (%s peak). %d workers active.        ', array_sum($numInQueue), implode('+', $numInQueue), $memory['used_memory_human'], $memory['used_memory_peak_human'], $lock->getNumberOfAcquiredLocks());
         $output->write("\r");
         $output->write($message);
         sleep(2);
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $systemCheck = new SystemCheck();
     $systemCheck->checkRedisIsInstalled();
     $backend = Queue\Factory::makeBackend();
     $lock = Queue\Factory::makeLock($backend);
     $keys = $lock->getAllAcquiredLockKeys();
     $keyToUnlock = $input->getOption('unlock');
     if ($keyToUnlock && in_array($keyToUnlock, $keys)) {
         $backend->delete($keyToUnlock);
         $this->writeSuccessMessage($output, array(sprintf('Key %s unlocked', $keyToUnlock)));
     } elseif ($keyToUnlock) {
         $output->writeln(sprintf('<error>%s is not or no longer locked</error>', $keyToUnlock));
         $output->writeln(' ');
     }
     foreach ($keys as $lockKey) {
         $time = $backend->getTimeToLive($lockKey);
         $output->writeln(sprintf('"%s" is locked for <comment>%d ms</comment>', $lockKey, $time));
         $output->writeln(sprintf('Set option <comment>--unlock=%s</comment> to unlock the queue.', $lockKey));
         $output->writeln(' ');
     }
 }
 public function test_makeLock_shouldReturnALockInstance()
 {
     $backend = Factory::makeBackend();
     $lock = Factory::makeLock($backend);
     $this->assertTrue($lock instanceof Queue\Lock);
 }