Skip to content

Okipa/laravel-supervisor-downtime-notifier

Repository files navigation

Laravel Supervisor Downtime Notifier

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

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!

Donate Donate

Compatibility

Laravel version PHP version Package version
^9.0 | ^10.0 8.1.* | 8.2.* ^2.4
^8.0 | ^9.0 ^8.1 | ^8.2 ^2.3
^8.0 | ^9.0 ^8.0 | ^8.1 ^2.2
^7.0 | ^8.0 ^7.4 | ^8.0 ^2.1
^7.0 | ^8.0 ^7.4 ^2.0
^6.0 | ^7.0 ^7.4 ^1.0

Upgrade guide

Table of Contents

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.