mirror of
https://github.com/wallabag/wallabag.git
synced 2025-01-03 05:18:40 +00:00
Display how many messages are queue
- update the docker-composer to add Redis - add migrations
This commit is contained in:
parent
5d002e9bdf
commit
e01a3c98d6
5 changed files with 118 additions and 0 deletions
42
app/DoctrineMigrations/Version20160911214952.php
Normal file
42
app/DoctrineMigrations/Version20160911214952.php
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<?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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ services:
|
||||||
links:
|
links:
|
||||||
- php:php
|
- php:php
|
||||||
command: nginx -c /nginx.conf
|
command: nginx -c /nginx.conf
|
||||||
|
|
||||||
php:
|
php:
|
||||||
build:
|
build:
|
||||||
context: docker/php
|
context: docker/php
|
||||||
|
@ -30,6 +31,7 @@ services:
|
||||||
# If all DBMS are commented out, sqlite will be used as default
|
# If all DBMS are commented out, sqlite will be used as default
|
||||||
# - ./docker/postgres/env
|
# - ./docker/postgres/env
|
||||||
# - ./docker/mariadb/env
|
# - ./docker/mariadb/env
|
||||||
|
|
||||||
#postgres:
|
#postgres:
|
||||||
# image: postgres:9
|
# image: postgres:9
|
||||||
# ports:
|
# ports:
|
||||||
|
@ -38,6 +40,7 @@ services:
|
||||||
# - ./docker/data/pgsql:/var/lib/postgresql/data
|
# - ./docker/data/pgsql:/var/lib/postgresql/data
|
||||||
# env_file:
|
# env_file:
|
||||||
# - ./docker/postgres/env
|
# - ./docker/postgres/env
|
||||||
|
|
||||||
#mariadb:
|
#mariadb:
|
||||||
# image: mariadb:10
|
# image: mariadb:10
|
||||||
# ports:
|
# ports:
|
||||||
|
@ -46,7 +49,13 @@ services:
|
||||||
# - ./docker/data/mariadb:/var/lib/mysql
|
# - ./docker/data/mariadb:/var/lib/mysql
|
||||||
# env_file:
|
# env_file:
|
||||||
# - ./docker/mariadb/env
|
# - ./docker/mariadb/env
|
||||||
|
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
image: rabbitmq:3-management
|
image: rabbitmq:3-management
|
||||||
ports:
|
ports:
|
||||||
- "15672:15672"
|
- "15672:15672"
|
||||||
|
|
||||||
|
rabbitmq:
|
||||||
|
image: redis
|
||||||
|
ports:
|
||||||
|
- "6379:6379"
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
Materialize.toast('{{ flashMessage|trans }}', 4000);
|
Materialize.toast('{{ flashMessage|trans }}', 4000);
|
||||||
</script>
|
</script>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
{{ render(controller("WallabagImportBundle:Import:checkQueue")) }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block menu %}
|
{% block menu %}
|
||||||
|
|
|
@ -16,4 +16,58 @@ class ImportController extends Controller
|
||||||
'imports' => $this->get('wallabag_import.chain')->getAll(),
|
'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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
{% 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 %}
|
Loading…
Reference in a new issue