okipa / laravel-stuck-jobs-notifier
Get notified when stuck jobs are detected.
Fund package maintenance!
Okipa
Ko Fi
paypal.me/arthurlorent
Installs: 8 449
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 3
Forks: 2
Open Issues: 0
Requires
- php: 8.1.*|8.2.*
- illuminate/contracts: ^9.0|^10.0
Requires (Dev)
- brianium/paratest: ^6.4
- laravel-notification-channels/webhook: ^2.4
- laravel/pint: ^1.1
- laravel/slack-notification-channel: ^2.5
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0
- orchestra/testbench: ^7.0|^8.0
- phpmd/phpmd: ^2.11
- roave/security-advisories: dev-latest
Suggests
- guzzlehttp/guzzle: Required for sending notifications via Slack
- laravel-notification-channels/webhook: Required for sending notifications via Webhook
- laravel/slack-notification-channel: Required for sending notifications via Slack
README
Get notified and execute PHP callback when you have stuck jobs for a defined number of hours.
Notifications can be sent by mail, Slack and webhooks (chats often provide a webhook API).
Found this package helpful? Please consider supporting my work!
Compatibility
Upgrade guide
Table of Contents
Installation
Install the package with composer:
composer require okipa/laravel-stuck-jobs-notifier
If you intend to send Slack
notifications you will have to install:
composer require laravel/slack-notification-channel
If you intend to send webhook
notifications you will have to install:
composer require laravel-notification-channels/webhook
Configuration
Publish the package configuration:
php artisan vendor:publish --tag=stuck-jobs-notifier:config
Translations
All words and sentences used in this package are translatable.
See how to translate them on the Laravel official documentation: https://laravel.com/docs/localization#using-translation-strings-as-keys.
Here is the list of the words and sentences available for translation by default:
* {1}[:app - :env] :count job is stuck in queue|[2,*][:app - :env] :count jobs are stuck in queue
* {1}We have detected that :count job is stuck in the [:app - :env](:url) queue since the :day at :hour.|[2,*]We have detected that :count jobs are stuck in the [:app - :env](:url) queue since the :day at :hour.
* Please check your stuck jobs connecting to your server and executing the "php artisan queue:failed" command.
* {1}`[:app - :env]` :count job is stuck in the :url queue since the :day at :hour.|[2,*]`[:app - :env]` :count jobs are stuck in the :url queue since the :day at :hour.
* {1}:count job is stuck in queue since the :day at :hour.|[2,*]:count jobs are stuck in queue since the :day at :hour.
* Notification test:
* Exception test:
Usage
Just add this command in the schedule()
method of your \App\Console\Kernel
class:
$schedule->command('queue:stuck:notify')->twiceDaily(10, 16);
And you will be notified as soon as some jobs will be stuck in the failed_jobs
table for the number of days you configured.
Once everything has been set up, you can check if the configuration is correct by simulating stuck jobs detection:
php artisan queue:stuck:simulate
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.