30

用 Supervisor 自启动、监控程序

 5 years ago
source link: https://shockerli.net/post/supervisor-launch-monitor/?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Supervisor 是 一个 Linux/Unix 系统上的进程监控工具。使用 Python 语言开发,提供 Web 管理界面,能够根据配置后台运行程序、监控程序、重启挂掉的程序等管理功能。

官网: http://www.supervisord.org

安装使用

在 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

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK