A simple way to detect when your queue workers are hanging or can't keep up.
Via Composer
$ composer require mortenscheel/laravel-heartbeat
Publish config
$ php artisan vendor:publish --tag=heartbeat-config
Default configuration
<?php
return [
/*
* When enabled, Laravel's sceduler will run the heartbeat:monitor
* command every minute, which will:
* 1. Dispatch heartbeat jobs on the configured queues.
* 2. Send an email to the configured recipients if a
* queue exceeds the maximum time between heartbeats.
*/
'enabled' => env('HEARTBEAT_ENABLED', false),
/*
* Maximum seconds between heartbeats, unless overridden.
*/
'default_threshold' => 120,
/*
* Which queues to monitor.
* To set a custom threshold, use the format
* 'queue_name' => maximum_seconds,
*/
'queues' => [
'default',
],
/*
* Recipients will receive an "Unhealthy heartbeat warning" e-mail
* when one or more queues exceed the configured threshold
*/
'recipients' => [
],
/*
* Minimum time between identical e-mail warnings
*/
'deduplication_minutes' => 1440,
/*
* Heartbeats are stored in the application cache (for 24 hours) with this cache prefix
*/
'cache_prefix' => 'heartbeat',
];
Enable heartbeat detection by adding the following variable to .env
:
HEARTBEAT_ENABLED=true
If Laravel's Scheduler is running via cron, the heartbeat:monitor
command will run automatically every minute.
To see the current status of queue heartbeats, you can run heartbeat:monitor
manually in the console:
$ php artisan heartbeat:monitor
+---------+----------------+-------------+
| Queue | Last heartbeat | Max allowed |
+---------+----------------+-------------+
| default | 1 minute ago | 2 minutes |
| high | 1 minute ago | 2 minutes |
| low | 1 minute ago | 3 minutes |
| encode | 2 minutes ago | 30 minutes |
+---------+----------------+-------------+
Please see the changelog for more information on what has changed recently.
$ composer test
Please see contributing.md for details and a todolist.
If you discover any security related issues, please email morten@mortenscheel.com instead of using the issue tracker.
license. Please see the license file for more information.