okipa / laravel-supervisor-downtime-notifier
当supervisor服务停止时接收通知。
2.4.0
2023-01-22 22:48 UTC
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
当
- supervisor服务在您的服务器上未运行时接收通知
- 您的环境supervisor进程已停止时接收通知
通知可以通过邮件、Slack和webhooks(聊天通常提供webhook API)发送。
觉得这个包很有用?请考虑支持我的工作!
兼容性
升级指南
目录
要求
默认情况下,此包监视在Linux服务器上运行的项目中的supervisor停机时间。
运行PHP CLI的用户将执行以下命令
systemctl is-active supervisor
supervisorctl status "<your-process-name>"
因此,请确保您已授予他执行这些操作的权限(sudo visudo -f /etc/sudoers.d/<user>
)
<user> ALL=NOPASSWD:/bin/systemctl is-active supervisor
<user> ALL=NOPASSWD:/usr/bin/supervisorctl status *
话虽如此,您仍然可以使用此包在其他服务器操作系统上,通过使用自己的SupervisorChecker
类并定义特定于OS的命令来实现。
安装
使用composer安装包
composer require okipa/laravel-supervisor-downtime-notifier
如果您打算发送Slack
通知,您必须安装
composer require laravel/slack-notification-channel
如果您打算发送webhook
通知,您必须安装
composer require laravel-notification-channels/webhook
配置
发布包配置
php artisan vendor:publish --tag=supervisor-downtime-notifier:config
翻译
此包中使用的所有单词和句子均可翻译。
有关如何翻译它们的信息,请参阅Laravel官方文档:https://laravel.net.cn/docs/localization#using-translation-strings-as-keys。
以下是默认可翻译的单词和句子列表
* [: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:
使用方法
只需将此命令添加到您的\App\Console\Kernel
类的schedule()
方法中
$schedule->command('supervisor:downtime:notify')->everyFifteenMinutes();
当命令执行时,如果您的supervisor服务未运行或环境supervisor进程已停止,您将收到通知。
一旦一切设置完成,您可以通过模拟supervisor进程停机来检查配置是否正确
php artisan supervisor:downtime:simulate
测试
composer test
变更日志
有关最近更改的详细信息,请参阅CHANGELOG。
贡献
有关详细信息,请参阅CONTRIBUTING。
鸣谢
许可
MIT许可(MIT)。有关更多信息,请参阅许可文件。