環(huán)境
系統(tǒng):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
-
添加啟動(dòng)服務(wù)
# 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
配置被管理進(jìn)程
# 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
啟動(dòng)
# systemctl enable supervisord.service
# systemctl start supervisord.service