mirror of
https://github.com/wallabag/wallabag.git
synced 2024-09-27 14:00:15 +00:00
b3437d58ae
- using javibravo/simpleue - internal config value are now `import_with_redis` & `import_with_rabbit` which are more clear - if both option are enable rabbit will be choosen - services imports related to async are now splitted into 2 files: `redis.yml` & `rabbit.yml` -
41 lines
1.5 KiB
PHP
41 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Wallabag\ImportBundle\Command;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
|
use Symfony\Component\Config\Definition\Exception\Exception;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Simpleue\Worker\QueueWorker;
|
|
|
|
class RedisWorkerCommand extends ContainerAwareCommand
|
|
{
|
|
protected function configure()
|
|
{
|
|
$this
|
|
->setName('wallabag:import:redis-worker')
|
|
->setDescription('Launch Redis worker')
|
|
->addArgument('serviceName', InputArgument::REQUIRED, 'Service to use: wallabag_v1, wallabag_v2, pocket or readability')
|
|
;
|
|
}
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
{
|
|
$output->writeln('Worker started at: '.(new \DateTime())->format('d-m-Y G:i:s'));
|
|
$output->writeln('Waiting for message ...');
|
|
|
|
$serviceName = $input->getArgument('serviceName');
|
|
|
|
if (!$this->getContainer()->has('wallabag_import.queue.redis.'.$serviceName) || !$this->getContainer()->has('wallabag_import.consumer.redis.'.$serviceName)) {
|
|
throw new Exception(sprintf('No queue or consumer found for service name: "%s"', $input->getArgument('serviceName')));
|
|
}
|
|
|
|
$worker = new QueueWorker(
|
|
$this->getContainer()->get('wallabag_import.queue.redis.'.$serviceName),
|
|
$this->getContainer()->get('wallabag_import.consumer.redis.'.$serviceName)
|
|
);
|
|
|
|
$worker->start();
|
|
}
|
|
}
|