-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
79 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,57 @@ | ||
# supervisor-event-listener | ||
Supervisor事件通知, 支持邮件, Slack, WebHook | ||
|
||
## 简介 | ||
Supervisor是*nix环境下的进程管理工具, 可以把前台进程转换为守护进程, 当进程异常退出时自动重启. | ||
supervisor-event-listener监听进程异常退出事件, 并发送通知. | ||
|
||
## 下载 | ||
[v1.0](https://github.com/ouqiang/supervisor-event-listener/releases) | ||
|
||
### 源码安装 | ||
* `go get -u github.com/ouqiang/supervisor-event-listener` | ||
|
||
## Supervisor配置 | ||
```ini | ||
[eventlistener:supervisor-event-listener] | ||
; 默认读取配置文件/etc/supervisor-event-listener.ini | ||
command=/path/to/supervisor-event-listener | ||
; 指定配置文件路径 | ||
;command=/path/to/supervisor-event-listener -c /path/to/supervisor-event-listener.ini | ||
events=PROCESS_STATE_EXITED | ||
...... | ||
``` | ||
|
||
## 配置文件, 默认读取`/etc/supervisor-event-listener.ini` | ||
|
||
```ini | ||
[default] | ||
# 通知类型 mail,slack,webhook 只能选择一种 | ||
notify_type = mail | ||
|
||
# 邮件服务器配置 | ||
mail.server.user = test@163.com | ||
mail.server.password = 123456 | ||
mail.server.host = smtp.163.com | ||
mail.server.port = 25 | ||
|
||
# 邮件收件人配置, 多个收件人, 逗号分隔 | ||
mail.user = hello@163.com | ||
|
||
# Slack配置 | ||
slack.webhook_url = https://hooks.slack.com/services/xxxx/xxx/xxxx | ||
slack.channel = exception | ||
|
||
# WebHook通知URL配置 | ||
webhook_url = http://my.webhook.com | ||
|
||
``` | ||
|
||
## 通知内容 | ||
邮件、Slack | ||
```shell | ||
Process: process-name | ||
Host: ip(hostname) | ||
EXITED FROM state: RUNNING | ||
PID: 6152 | ||
``` | ||
WebHook, Post请求, 字段含义查看Supervisor文档 | ||
```json | ||
{ | ||
"Header": { | ||
"Ver": "3.0", | ||
"Server": "supervisor", | ||
"Serial": 11, | ||
"Pool": "supervisor-listener", | ||
"PoolSerial": 11, | ||
"EventName": "PROCESS_STATE_EXITED", | ||
"Len": 84 | ||
}, | ||
"Payload": { | ||
"Ip": "ip(hostname)", | ||
"ProcessName": "process-name", | ||
"GroupName": "group-name", | ||
"FromState": "RUNNING", | ||
"Expected": 0, | ||
"Pid": 6371 | ||
} | ||
} | ||
``` | ||
# Introduction | ||
A `eventlistener` for supervisor, it may listen and redirect events to e-mail, webhook, slack and so on. | ||
More details http://supervisord.org/events.html | ||
|
||
# Features | ||
* support e-mail, webhook, slack | ||
* support bearychat, lack(feishu) | ||
|
||
# Usage | ||
|
||
1. setup supervisor-eventlistener | ||
```toml | ||
[mail] | ||
receivers = ["hello@163.com", "world@163.com"] | ||
server_user = "test@163.com" | ||
server_password = "123456" | ||
server_host = "smtp.163.com" | ||
server_port = 25 | ||
|
||
[slack] | ||
url = "https://hooks.slack.com/services/xxxx/xxx/xxxx" | ||
channel = "exception" | ||
timeout = 6 | ||
|
||
[webhook] | ||
url = "http://my.webhook.com" | ||
timeout = 6 | ||
|
||
[bearychat] | ||
url = "https://hook.bearychat.com/xxx/xxxx" | ||
channel = "alert" | ||
timeout = 6 | ||
|
||
[feishu] | ||
url = "https://hook.feishu.com/xxx/xxxx?signKey=it_is_optional" | ||
timeout = 6 | ||
``` | ||
|
||
2. setup supervisor | ||
```ini | ||
[eventlistener:supervisor-event-listener] | ||
command=/usr/local/bin/supervisor-event-listener -c /etc/supervisor-event-listener.toml | ||
user=nobody | ||
group=nobody | ||
events= | ||
PROCESS_STATE_EXITED, | ||
PROCESS_STATE_FATAL, | ||
PROCESS_STATE_STOPPED, | ||
PROCESS_STATE_RUNNING | ||
``` | ||
|
||
3. start supervisor-eventlistener | ||
```bash | ||
supervisorctl start supervisor-event-listener | ||
``` | ||
|
||
That's all. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.