supervisor 重启_Supervisor守护进程安装
介绍
Supervisor是比较常用的进程管理工具,支持 Linux/MacOS平台,可以用来控制一组Linux/Unix进程(启动、重启、kill)等,使用Supervisor管理的进程,可以做到以守护进程的方式运行,服务异常关闭后可以自动重启。
Supervisor 有下面几个组件:
supervisord: Supervisor的服务端程序,使用前,需要先启动该组件;
supervisorctl: Supervisor的客户端程序,用来实际控制子进程(自定义的服务、程序);
Supervisor 通过配置文件,还可以启动Web控制台,通过Web页面来管理子进程;
安装
[root@ ~]# yum -y install python-setuptools[root@ ~]# easy_install supervisor[root@ ~]# supervisord -v
配置
[root@ ~]# mkdir /etc/supervisor[root@ ~]# echo_supervisord_conf > /etc/supervisord.conf[root@ ~]# vi /etc/supervisord.conf;修改include配置,去除注释[include]files = /etc/supervisor/*.conf#开启web远程查看[inet_http_server] ; inet (TCP) server disabled by defaultport=*:9001 ; ip_address:port specifier, 0.0.0.0:port for all ifaceusername=user ; default is no username (open server)password=123 ; default is no password (open server)
配置开机启动
[root@ ~]# vi /lib/systemd/system/supervisor.service[Unit]Description=supervisorAfter=network.target[Service]Type=forkingExecStart=/usr/bin/supervisord -c /etc/supervisord.confExecStop=/usr/bin/supervisorctl $OPTIONS shutdownExecReload=/usr/bin/supervisorctl $OPTIONS reloadKillMode=processRestart=on-failureRestartSec=42s[Install]WantedBy=multi-user.target
开启服务
[root@ ~]# systemctl enable supervisor.service
启动服务
[root@ ~]# supervisord -c /etc/supervisord.conf
命令
1.启动任务supervisorctl start 服务名2.停止任务supervisorctl stop 服务名3.重启任务supervisorctl restart 服务名4.增加任务之后updatesupervisorctl update5.停止supervisordsupervisorctl shutdown6.重新加载配置文件,停止原有进程并按新的配置启动、管理所有进程supervisorctl reload7.关闭、开启所有进程supervisorctl stop allsupervisorctl start all8.关闭、开启指定进程supervisorctl stop redash_celerysupervisorctl start redash_celery9.查看所有子进程的状态supervisorctl status
1.启动任务supervisorctl start 服务名2.停止任务supervisorctl stop 服务名3.重启任务supervisorctl restart 服务名4.增加任务之后updatesupervisorctl update5.停止supervisordsupervisorctl shutdown6.重新加载配置文件,停止原有进程并按新的配置启动、管理所有进程supervisorctl reload7.关闭、开启所有进程supervisorctl stop allsupervisorctl start all8.关闭、开启指定进程supervisorctl stop redash_celerysupervisorctl start redash_celery9.查看所有子进程的状态supervisorctl status