okipa/laravel-stuck-jobs-notifier

Get notified when stuck jobs are detected.

2.4.0 2023-01-22 22:48 UTC

This package is auto-updated.

Last update: 2024-11-19 23:41:03 UTC


README

Laravel Stuck Jobs Notifier

Latest Stable Version Total Downloads Build Status Coverage Status License: MIT

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!

Donate Donate

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.