Supervisor事件通知

supervisor-event-listener

Supervisor事件通知, 支持郵件, Slack, WebHookgit

簡介

Supervisor是*nix環境下的進程管理工具, 能夠把前臺進程轉換爲守護進程, 當進程異常退出時自動重啓.
supervisor-event-listener監聽進程異常退出事件, 併發送通知.github

項目地址

supervisor-event-listenerweb

Supervisor配置

[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

[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

通知內容

郵件、Slackshell

Host: ip(hostname)
Process: process-name
PID: 6152
EXITED FROM state: RUNNING

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
  }
}
相關文章
相關標籤/搜索