supervisorctl命令的使用讲解
1. 入门介绍
supervisor主要的作用是管理进程,主要通过fork/exec进程对其启动(将其作为子进程),之后supervisor作为父进程对其启动,即使断电宕机也可将其重启,主要在配置文件中书写autostart=true即可。而传统方式的当即重启脚本需要写一个脚本来监控
对比传统方式的书写,supervisor的特性作用比较大
supervisorctl 主要是supervisor的一个客户端管理工具,主要用来管理进程
下载这个命令完成之后,其命令的配置文件路径在:cat /etc/supervisor/supervisord.conf
具体的参数讲解:
子进程名
运行状态(RUNNING、FATAL、STOPPED、STARTING)
进程号或者子进程的运行时间
查看单个子进程的状态: supervisorctl status 子进程
关闭单个子进程 :supervisorctl stop 子进程
关闭所有子进程:supervisorctl stop all
启动单个子进程:supervisorctl start 子进程
启动所有子进程:supervisorctl start all
重启单个子进程:supervisorctl restart 子进程
配置文件
将其脚本配置在文件中
其配置文件的详解具体如下:(我的目录在conf文件下)
[program:supervisorctl文件名]
# 主目录
directory=/home/xx
# 执行虚拟环境的命令
command=/home/xx/.virtualenvs/audioadmin/bin/uwsgi --ini uwsgi.ini
# 用户名是这个
user=root
numprocs=1
# 日志文件
stdout_logfile=/home/xx/logs/uwsgi.log
redirect_stderr=true
autostart=false
autorestart=true
startsecs=5
stopwaitsecs=10
killasgroup=true
priority=999
stopsignal=QUIT