--- /dev/null
+<?php
+
+namespace Application\Migrations;
+
+use Doctrine\DBAL\Migrations\AbstractMigration;
+use Doctrine\DBAL\Schema\Schema;
+use Symfony\Component\DependencyInjection\ContainerAwareInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+class Version20160911214952 extends AbstractMigration implements ContainerAwareInterface
+{
+ /**
+ * @var ContainerInterface
+ */
+ private $container;
+
+ public function setContainer(ContainerInterface $container = null)
+ {
+ $this->container = $container;
+ }
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
+
+ /**
+ * @param Schema $schema
+ */
+ public function up(Schema $schema)
+ {
+ $this->addSql('INSERT INTO `'.$this->getTable('craue_config_setting').'` (`name`, `value`, `section`) VALUES (\'import_with_redis\', \'0\', \'import\')');
+ $this->addSql('INSERT INTO `'.$this->getTable('craue_config_setting').'` (`name`, `value`, `section`) VALUES (\'import_with_rabbitmq\', \'0\', \'import\')');
+ }
+
+ /**
+ * @param Schema $schema
+ */
+ public function down(Schema $schema)
+ {
+ }
+}
links:
- php:php
command: nginx -c /nginx.conf
+
php:
build:
context: docker/php
# If all DBMS are commented out, sqlite will be used as default
# - ./docker/postgres/env
# - ./docker/mariadb/env
+
#postgres:
# image: postgres:9
# ports:
# - ./docker/data/pgsql:/var/lib/postgresql/data
# env_file:
# - ./docker/postgres/env
+
#mariadb:
# image: mariadb:10
# ports:
# - ./docker/data/mariadb:/var/lib/mysql
# env_file:
# - ./docker/mariadb/env
+
rabbitmq:
image: rabbitmq:3-management
ports:
- "15672:15672"
+
+ rabbitmq:
+ image: redis
+ ports:
+ - "6379:6379"
Materialize.toast('{{ flashMessage|trans }}', 4000);
</script>
{% endfor %}
+
+ {{ render(controller("WallabagImportBundle:Import:checkQueue")) }}
{% endblock %}
{% block menu %}
'imports' => $this->get('wallabag_import.chain')->getAll(),
]);
}
+
+ /**
+ * Display how many messages are queue (both in Redis and RabbitMQ).
+ */
+ public function checkQueueAction()
+ {
+ $nbRedisMessages = null;
+ $nbRabbitMessages = null;
+
+ if ($this->get('craue_config')->get('import_with_rabbitmq')) {
+ $nbRabbitMessages = $this->getTotalMessageInRabbitQueue('pocket')
+ + $this->getTotalMessageInRabbitQueue('readability')
+ + $this->getTotalMessageInRabbitQueue('wallabag_v1')
+ + $this->getTotalMessageInRabbitQueue('wallabag_v2')
+ ;
+ } elseif ($this->get('craue_config')->get('import_with_redis')) {
+ $redis = $this->get('wallabag_core.redis.client');
+
+ $nbRedisMessages = $redis->llen('wallabag.import.pocket')
+ + $redis->llen('wallabag.import.readability')
+ + $redis->llen('wallabag.import.wallabag_v1')
+ + $redis->llen('wallabag.import.wallabag_v2')
+ ;
+ }
+
+ return $this->render('WallabagImportBundle:Import:check_queue.html.twig', [
+ 'nbRedisMessages' => $nbRedisMessages,
+ 'nbRabbitMessages' => $nbRabbitMessages,
+ ]);
+ }
+
+ /**
+ * Count message in RabbitMQ queue.
+ * It get one message without acking it (so it'll stay in the queue)
+ * which will include the total of *other* messages in the queue.
+ * Adding one to that messages will result in the full total message.
+ *
+ * @param string $importService The import service related: pocket, readability, wallabag_v1 or wallabag_v2
+ *
+ * @return int
+ */
+ private function getTotalMessageInRabbitQueue($importService)
+ {
+ $message = $this
+ ->get('old_sound_rabbit_mq.import_'.$importService.'_consumer')
+ ->getChannel()
+ ->basic_get('wallabag.import.'.$importService);
+
+ if (null === $message) {
+ return 0;
+ }
+
+ return $message->delivery_info['message_count'] + 1;
+ }
}
--- /dev/null
+{% if nbRedisMessages > 0 %}
+ <script>
+ Materialize.toast('Messages in queue: {{ nbRedisMessages }}', 4000);
+ </script>
+{% endif %}
+
+{% if nbRabbitMessages > 0 %}
+ <script>
+ Materialize.toast('Messages in queue: {{ nbRabbitMessages }}', 4000);
+ </script>
+{% endif %}