/yii2-queue-monitor

Yii2 Queue Analytics Module

Primary LanguagePHPBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Yii2 Queue Analytics Module

The module collects statistics about working of queues of an application, and provides web interface for research. Also the module allows to stop and replay any jobs manually.

This library is fork of https://github.com/zhuravljov/yii2-queue-monitor. Major change is storage to mongodb.

Latest Stable Version Total Downloads Scrutinizer Code Quality

Installation

The preferred way to install the extension is through composer. Add to the require section of your composer.json file:

"zhuravljov/yii2-queue-monitor": "~0.1"

Usage

To configure the statistics collector, you need to add monitor behavior for each queue component. Update common config file:

return [
    'components' => [
        'queue' => [
            // ...
            'as jobMonitor' => \zhuravljov\yii\queue\monitor\JobMonitor::class,
            'as workerMonitor' => \zhuravljov\yii\queue\monitor\WorkerMonitor::class,
        ],
    ],
];

There are storage options that you can configure by common config file:

return [
    'container' => [
        'singletons' => [
            \zhuravljov\yii\queue\monitor\Env::class => [
                'cache' => 'cache',
                'db' => 'mongodb',
                'pushTableName'   => 'queue_push',
                'execTableName'   => 'queue_exec',
                'workerTableName' => 'queue_worker',
            ],
        ],
    ],
];

Web

Finally, modify your web config file to turn on web interface:

return [
    'bootstrap' => [
        'monitor',
    ],
    'modules' => [
        'monitor' => [
            'class' => \zhuravljov\yii\queue\monitor\Module::class,
        ],
    ],
];

It will be available by URL http://yourhost.com/monitor.

Console

There is console garbage collector:

'controllerMap' => [
    'monitor' => [
        'class' => \zhuravljov\yii\queue\monitor\console\GcController::class,
    ],
],

It can be executed as:

php yii monitor/clear-deprecated P1D

Where P1D is interval spec that specifies to delete all records one day older.