用 Supervisor 自启动、监控程序
51reboot · · 1727 次点击 · · 开始浏览Supervisor 是 一个 Linux/Unix 系统上的进程监控工具。使用 Python 语言开发,提供 Web 管理界面,能够根据配置后台运行程序、监控程序、重启挂掉的程序等管理功能。
安装使用
在 Ubuntu 上可以使用apt-get install supervisor,在 CentOS 上可以使用yum install supervisor。但这些基于源的方式安装,可能版本比较老。所以推荐使用easy_install安装:
easy_install supervisor
生成默认配置文件:
echo_supervisord_conf > /etc/supervisord.conf
安装完后,主要有3个命令,分别是:
-
echo_superisord_conf- 生成默认配置文件 -
supervisord- 服务端 -
supervisorctl- 客户端
修改/etc/supervisord.conf,引入程序配置文件:
[include]
files = /etc/supervisord/*.conf
程序配置示例
[program:demo]
directory = /opt/soft/demo/
command = /opt/soft/demo/demo
autostart = true
autorestart = true
startsecs = 5
user = upfor
redirect_stderr = true
stdout_logfile = /var/log/supervisord/stdout.demo.log
stdout_logfile_maxbytes = 1MB
stdout_logfile_backups = 10
stdout_capture_maxbytes = 1MB
stderr_logfile = /var/log/supervisord/stderr.demo.log
stderr_logfile_maxbytes = 1MB
stderr_logfile_backups = 10
stderr_capture_maxbytes = 1MB
文章作者 Jioby
原文链接 https://shockerli.net/post/supervisor-launch-monitor/
51reboot golang课程第4期6.15日开课
51reboot 运维前端课程正在火热招生中
详情联系WeChat;17812796384
有疑问加站长微信联系(非本文作者)
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
关注微信- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码` - 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传
收入到我管理的专栏 新建专栏
Supervisor 是 一个 Linux/Unix 系统上的进程监控工具。使用 Python 语言开发,提供 Web 管理界面,能够根据配置后台运行程序、监控程序、重启挂掉的程序等管理功能。
安装使用
在 Ubuntu 上可以使用apt-get install supervisor,在 CentOS 上可以使用yum install supervisor。但这些基于源的方式安装,可能版本比较老。所以推荐使用easy_install安装:
easy_install supervisor
生成默认配置文件:
echo_supervisord_conf > /etc/supervisord.conf
安装完后,主要有3个命令,分别是:
-
echo_superisord_conf- 生成默认配置文件 -
supervisord- 服务端 -
supervisorctl- 客户端
修改/etc/supervisord.conf,引入程序配置文件:
[include]
files = /etc/supervisord/*.conf
程序配置示例
[program:demo]
directory = /opt/soft/demo/
command = /opt/soft/demo/demo
autostart = true
autorestart = true
startsecs = 5
user = upfor
redirect_stderr = true
stdout_logfile = /var/log/supervisord/stdout.demo.log
stdout_logfile_maxbytes = 1MB
stdout_logfile_backups = 10
stdout_capture_maxbytes = 1MB
stderr_logfile = /var/log/supervisord/stderr.demo.log
stderr_logfile_maxbytes = 1MB
stderr_logfile_backups = 10
stderr_capture_maxbytes = 1MB
文章作者 Jioby
原文链接 https://shockerli.net/post/supervisor-launch-monitor/