环境
系统:CentOS 7.8
方法一:使用pip安装
-
安装
# pip install supervisor
-
生成主配置
# echo_supervisord_conf > /etc/supervisord.conf
# vim /etc/supervisord.conf [unix_http_server] file=/var/run/supervisor.sock [supervisord] pidfile=/var/run/supervisor.pid [supervisorctl] serverurl=unix:///var/run/supervisor.sock [include] files=/etc/supervisor/*.ini
-
添加启动服务
# vim /usr/lib/systemd/system/supervisord.service [Unit] Description=Process Monitoring and Control Daemon After=rc-local.service nss-user-lookup.target [Service] Type=forking ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf [Install] WantedBy=multi-user.target
方法二:使用yum安装
- 安装
# yum install supervisor
配置被管理进程
# vim /etc/supervisor/my_app.ini
[program:my_app]
command=/usr/local/jdk/bin/java -jar my_app.jar
directory=/data/app/%(program_name)s
user=root
redirect_stderr=true
stdout_logfile=/data/logs/%(program_name)s.log
stdout_logfile_maxbytes=500MB
启动
# systemctl enable supervisord.service
# systemctl start supervisord.service