okipa / laravel-supervisor-downtime-notifier
Get notified when supervisor is down.
Fund package maintenance!
Okipa
Ko Fi
paypal.me/arthurlorent
Installs: 8 056
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 3
Forks: 2
Open Issues: 1
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:
- The supervisor service is not running on your server
- Your environment supervisor processes are down
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
- Requirements
- Installation
- Configuration
- Translations
- Usage
- Testing
- Changelog
- Contributing
- Credits
- Licence
Requirements
By default, this package monitors supervisor downtime for projects running on Linux servers.
The user running PHP CLI will execute the following commands:
systemctl is-active supervisor
supervisorctl status "<your-process-name>"
As so, make sure you give him permission to execute these actions (sudo visudo -f /etc/sudoers.d/<user>
):
<user> ALL=NOPASSWD:/bin/systemctl is-active supervisor
<user> ALL=NOPASSWD:/usr/bin/supervisorctl status *
That being said, you still can use this package for other servers OS by using your own SupervisorChecker
class and defining OS-specific commands.
Installation
Install the package with composer:
composer require okipa/laravel-supervisor-downtime-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=supervisor-downtime-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:
* [:app - :env] supervisor service is not started
* We have detected that the supervisor service is not started on [:app - :env](:url).
* `[:app - :env]` supervisor service is not started on :url.
* Supervisor service is not started.
* {1}[:app - :env] :count supervisor down process has been detected|[2,*][:app - :env] :count supervisor down processes have been detected
* {1}We have detected :count supervisor down process on [:app - :env](:url): ":processes".|[2,*]We have detected :count supervisor down processes on [:app - :env](:url): ":processes".
* Please check your down processes connecting to your server and executing the "supervisorctl status" command.
* {1}`[:app - :env]` :count supervisor down process has been detected on :url: ":processes".|[2,*]`[:app - :env]` :count supervisor down processes have been detected on :url: ":processes".
* {1}:count supervisor down process has been detected: ":processes".|[2,*]:count supervisor down processes have been detected: ":processes".
* Notification test:
* Exception test:
Usage
Just add this command in the schedule()
method of your \App\Console\Kernel
class:
$schedule->command('supervisor:downtime:notify')->everyFifteenMinutes();
And you will be notified if your supervisor service is not running, or if your environment supervisor processes are down when the command will be executed.
Once everything has been set up, you can check if the configuration is correct by simulating supervisor processes downtime:
php artisan supervisor:downtime: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.