aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--app/DoctrineMigrations/Version20160911214952.php42
-rw-r--r--docker-compose.yml9
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig2
-rw-r--r--src/Wallabag/ImportBundle/Controller/ImportController.php54
-rw-r--r--src/Wallabag/ImportBundle/Resources/views/Import/check_queue.html.twig11
5 files changed, 118 insertions, 0 deletions
diff --git a/app/DoctrineMigrations/Version20160911214952.php b/app/DoctrineMigrations/Version20160911214952.php
new file mode 100644
index 00000000..35809cec
--- /dev/null
+++ b/app/DoctrineMigrations/Version20160911214952.php
@@ -0,0 +1,42 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10class Version20160911214952 extends AbstractMigration implements ContainerAwareInterface
11{
12 /**
13 * @var ContainerInterface
14 */
15 private $container;
16
17 public function setContainer(ContainerInterface $container = null)
18 {
19 $this->container = $container;
20 }
21
22 private function getTable($tableName)
23 {
24 return $this->container->getParameter('database_table_prefix') . $tableName;
25 }
26
27 /**
28 * @param Schema $schema
29 */
30 public function up(Schema $schema)
31 {
32 $this->addSql('INSERT INTO `'.$this->getTable('craue_config_setting').'` (`name`, `value`, `section`) VALUES (\'import_with_redis\', \'0\', \'import\')');
33 $this->addSql('INSERT INTO `'.$this->getTable('craue_config_setting').'` (`name`, `value`, `section`) VALUES (\'import_with_rabbitmq\', \'0\', \'import\')');
34 }
35
36 /**
37 * @param Schema $schema
38 */
39 public function down(Schema $schema)
40 {
41 }
42}
diff --git a/docker-compose.yml b/docker-compose.yml
index a255b070..27f0f14f 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -11,6 +11,7 @@ services:
11 links: 11 links:
12 - php:php 12 - php:php
13 command: nginx -c /nginx.conf 13 command: nginx -c /nginx.conf
14
14 php: 15 php:
15 build: 16 build:
16 context: docker/php 17 context: docker/php
@@ -30,6 +31,7 @@ services:
30 # If all DBMS are commented out, sqlite will be used as default 31 # If all DBMS are commented out, sqlite will be used as default
31 # - ./docker/postgres/env 32 # - ./docker/postgres/env
32 # - ./docker/mariadb/env 33 # - ./docker/mariadb/env
34
33 #postgres: 35 #postgres:
34 # image: postgres:9 36 # image: postgres:9
35 # ports: 37 # ports:
@@ -38,6 +40,7 @@ services:
38 # - ./docker/data/pgsql:/var/lib/postgresql/data 40 # - ./docker/data/pgsql:/var/lib/postgresql/data
39 # env_file: 41 # env_file:
40 # - ./docker/postgres/env 42 # - ./docker/postgres/env
43
41 #mariadb: 44 #mariadb:
42 # image: mariadb:10 45 # image: mariadb:10
43 # ports: 46 # ports:
@@ -46,7 +49,13 @@ services:
46 # - ./docker/data/mariadb:/var/lib/mysql 49 # - ./docker/data/mariadb:/var/lib/mysql
47 # env_file: 50 # env_file:
48 # - ./docker/mariadb/env 51 # - ./docker/mariadb/env
52
49 rabbitmq: 53 rabbitmq:
50 image: rabbitmq:3-management 54 image: rabbitmq:3-management
51 ports: 55 ports:
52 - "15672:15672" 56 - "15672:15672"
57
58 rabbitmq:
59 image: redis
60 ports:
61 - "6379:6379"
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
index b70198da..23938b21 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
@@ -19,6 +19,8 @@
19 Materialize.toast('{{ flashMessage|trans }}', 4000); 19 Materialize.toast('{{ flashMessage|trans }}', 4000);
20 </script> 20 </script>
21 {% endfor %} 21 {% endfor %}
22
23 {{ render(controller("WallabagImportBundle:Import:checkQueue")) }}
22{% endblock %} 24{% endblock %}
23 25
24{% block menu %} 26{% block menu %}
diff --git a/src/Wallabag/ImportBundle/Controller/ImportController.php b/src/Wallabag/ImportBundle/Controller/ImportController.php
index c1486e38..d670746c 100644
--- a/src/Wallabag/ImportBundle/Controller/ImportController.php
+++ b/src/Wallabag/ImportBundle/Controller/ImportController.php
@@ -16,4 +16,58 @@ class ImportController extends Controller
16 'imports' => $this->get('wallabag_import.chain')->getAll(), 16 'imports' => $this->get('wallabag_import.chain')->getAll(),
17 ]); 17 ]);
18 } 18 }
19
20 /**
21 * Display how many messages are queue (both in Redis and RabbitMQ).
22 */
23 public function checkQueueAction()
24 {
25 $nbRedisMessages = null;
26 $nbRabbitMessages = null;
27
28 if ($this->get('craue_config')->get('import_with_rabbitmq')) {
29 $nbRabbitMessages = $this->getTotalMessageInRabbitQueue('pocket')
30 + $this->getTotalMessageInRabbitQueue('readability')
31 + $this->getTotalMessageInRabbitQueue('wallabag_v1')
32 + $this->getTotalMessageInRabbitQueue('wallabag_v2')
33 ;
34 } elseif ($this->get('craue_config')->get('import_with_redis')) {
35 $redis = $this->get('wallabag_core.redis.client');
36
37 $nbRedisMessages = $redis->llen('wallabag.import.pocket')
38 + $redis->llen('wallabag.import.readability')
39 + $redis->llen('wallabag.import.wallabag_v1')
40 + $redis->llen('wallabag.import.wallabag_v2')
41 ;
42 }
43
44 return $this->render('WallabagImportBundle:Import:check_queue.html.twig', [
45 'nbRedisMessages' => $nbRedisMessages,
46 'nbRabbitMessages' => $nbRabbitMessages,
47 ]);
48 }
49
50 /**
51 * Count message in RabbitMQ queue.
52 * It get one message without acking it (so it'll stay in the queue)
53 * which will include the total of *other* messages in the queue.
54 * Adding one to that messages will result in the full total message.
55 *
56 * @param string $importService The import service related: pocket, readability, wallabag_v1 or wallabag_v2
57 *
58 * @return int
59 */
60 private function getTotalMessageInRabbitQueue($importService)
61 {
62 $message = $this
63 ->get('old_sound_rabbit_mq.import_'.$importService.'_consumer')
64 ->getChannel()
65 ->basic_get('wallabag.import.'.$importService);
66
67 if (null === $message) {
68 return 0;
69 }
70
71 return $message->delivery_info['message_count'] + 1;
72 }
19} 73}
diff --git a/src/Wallabag/ImportBundle/Resources/views/Import/check_queue.html.twig b/src/Wallabag/ImportBundle/Resources/views/Import/check_queue.html.twig
new file mode 100644
index 00000000..7168ea35
--- /dev/null
+++ b/src/Wallabag/ImportBundle/Resources/views/Import/check_queue.html.twig
@@ -0,0 +1,11 @@
1{% if nbRedisMessages > 0 %}
2 <script>
3 Materialize.toast('Messages in queue: {{ nbRedisMessages }}', 4000);
4 </script>
5{% endif %}
6
7{% if nbRabbitMessages > 0 %}
8 <script>
9 Materialize.toast('Messages in queue: {{ nbRabbitMessages }}', 4000);
10 </script>
11{% endif %}