介绍
supervisor可以对进程进行监管,当进程挂掉,可以对进程进行重启,不用编写额外的脚步进行控制。
名词
supervisor:安装的软件的名称。
supervisord:装好supervisor后,supervisord用于启动supervisor服务。
supervisorctl:用于管理supervisor配置文件中program和supervisor服务本身。
安装
yum install epel-release
yum install supervisor
启动
指定配置文件启动, 推荐使用该方法
supervisord -c /etc/supervisord.conf
备注:supervisor的配置文件默认是不全的,不过在大部分默认的情况下,基本功能已经满足。安装好supervisor后,输入以下命令可得到配置文件
echo_supervisord_conf
日志
supervisor遇到错误,在/var/log/supervisord.log中查看日志。
app运行出现问题,在/srv/awesome/log/app.log中查看日志。
查看进程
ps aux | grep supervisord
查看状态
可以通过命令
systemctl status supervisord
或者登录服务器IP,加指定端口即可登录图形界面
开机启动
在 /lib/systemd/system 目录简历文件 supervisord.service
vim /lib/systemd/system/supervisord.service
输入内容
[Unit]
Description=Supervisor daemon
[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf
ExecStop=/usr/bin/supervisorctl shutdown
ExecReload=/usr/bin/supervisorctl reload
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
启动开机启动
systemctl enable supervisord
守护进程
指定子进程目录,即每个守护进程,的启动文件。
files = supervisord.conf当前目录下的目录/*.ini
*.ini文件 。内容:
[program:consul]
directory=/usr/local/consul-0.7.5
command=/bin/sh start_consul.sh
autostart=true
autorestart=false
startsecs=1
stderr_logfile=/log/consul/err.log
stdout_logfile=/log/consul/out.log
user = root
redirect_stderr = true
asgfjfghfc_maxbytes = 20M
stdout_logfile_backups = 20
2022年10月17日 21:30:02
These are genuinely wonderful ideas in about blogging. You have touched some good things here. Any way keep up wrinting.
Hello There. I discovered your blog using msn. That is a really neatly written article. I will be sure to bookmark it and return to read extra of your useful info. Thank you for the post. I will certainly comeback.
反正都是草民,谁管都一样。
为什么我rss抓不到更新啊
Fine way of telling, and pleasant post to obtain data regarding my presentation subject, which i am going to deliver in college.
给我友联改好