PHP code example of codingducksrl / laravel-queue-monitor

1. Go to this page and download the library: Download codingducksrl/laravel-queue-monitor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

codingducksrl / laravel-queue-monitor example snippets


// config/queue-monitor.php
'queues' => ['redis' => ['default', 'high']],

// routes/console.php
Schedule::command('queue-monitor:sample')
    ->everyMinute()
    ->onOneServer()
    ->runInBackground()
    ->appendOutputTo('/proc/1/fd/1');

// config/database.php, under 'redis'
'metrics' => [
    'host' => env('REDIS_METRICS_HOST', '127.0.0.1'),
    'username' => env('REDIS_METRICS_USERNAME'),
    'password' => env('REDIS_METRICS_PASSWORD'),
    'port' => env('REDIS_METRICS_PORT', '6379'),
    'database' => env('REDIS_METRICS_DB', '3'),
    'timeout' => 0.2,
    'read_timeout' => 0.2,       // phpredis
    'read_write_timeout' => 0.2, // predis
    'max_retries' => 1,          // phpredis
],

// config/cache.php, under 'stores'
'metrics' => ['driver' => 'redis', 'connection' => 'metrics', 'lock_connection' => 'metrics'],

use CodingDuck\QueueMonitor\MetricSinkManager;

$this->app->make(MetricSinkManager::class)->extend('datadog', function ($app) {
    return new DatadogSink($app->make('datadog.client'));
});
bash
php artisan vendor:publish --tag=queue-monitor-config
bash
php artisan queue-monitor:status
bash
php artisan queue-monitor:status                              # configuration and readiness check
php artisan queue-monitor:sample                              # what the schedule runs: publish and drain
php artisan queue-monitor:sample --dry-run                    # print without publishing or draining
php artisan queue-monitor:sample redis:high,database:default  # explicit connection:queue pairs