接收主管进程事件的通知。
supervisor-alert的Python项目详细描述
主管警报
你是用Supervisor来管理 服务器上的进程?使用主管提醒,您可以接收消息 当进程的状态改变时。第一个知道 服务死了!
使用默认配置管理器警报发送消息 电报。要使其正常工作,您需要安装 telegram-send系统范围 第一。也可以使用任何shell命令发送通知。
安装
在系统上安装主管警报:
sudo pip install supervisor-alert
您必须使用python 2安装它,因为supervisor不支持 Python3号。对于supervisor 4+,如果 python3 -c 'import supervisor'没有错误,您应该 使用pip3/python3安装主管警报。
然后运行:
sudo supervisor-alert --configure
对于默认配置。这将发送通知 电报。阅读下一节进行自定义,或者如果您不喜欢自动 配置。
手动配置
创建文件/etc/supervisor/conf.d/supervisor_alert.confas 根目录:
[eventlistener:supervisor_alert]command=supervisor-alert --telegram events=PROCESS_STATE_RUNNING,PROCESS_STATE_EXITED,PROCESS_STATE_FATAL autostart=trueautorestart=truestdout_logfile=NONE user=supervisor_alert
这将通过电报发送通知,使用其他东西, 例如ntfy,传入 命令:
command=supervisor-alert -c 'ntfy send'
默认情况下,/etc/telegram-send.conf处的配置文件用于 电报发送、使用其他配置或传递任何其他选项:
command=supervisor-alert -c 'telegram-send --config /home/user/bunny.conf'
也可以在每条消息之前显示主机名 --show-hostname选项:
command=supervisor-alert --telegram --show-hostname
默认配置将以用户身份运行事件侦听器 supervisor_alert。将服务隔离为 将它们作为单独的用户运行(并避免将它们作为根用户运行)。添加 用户:
sudo adduser supervisor_alert --system --no-create-home
或者,您也可以订阅不同的主管事件,look at the docs以查看 你想在哪些方面得到通知。
最后,加载配置并启动事件侦听器:
sudo supervisorctl reread sudo supervisorctl update
现在您应该收到第一个警报,通知您 supervisor_alert已开始运行。