supervisor 使用 Python开发的进程管理工具,可以方便的对用户定义的进程进行启动、关闭、重启,并可以对以为关闭的进程重启;且可以监控执行状态、日志输出等。
supervisor 安装 1 yum -y install supervisor
安装路径 /usr/bin/supervisord
, 配置文件 /etc/supervisor.conf
supervisor启动 手动启动 1 /usr/ bin/supervisord -c / etc/supervisor.conf
手动关闭 1 /usr/bin/supervisorctl stop all
自动启动
1 2 3 vim /etc/ supervisrod.conf nodaemon=false 改成true
或者编辑 vi /etc/rc.local
实现开机启动,添加在 exit 0
前
1 /usr/ local/bin/ supervisord
配置说明 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 [unix_http_server] file =/tmp/supervisor.sock [supervisord] logfile =/tmp/supervisord.log logfile_maxbytes =50 MB logfile_backups =10 loglevel =info pidfile =/tmp/supervisord.pid nodaemon =false minfds =1024 minprocs =200 [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface[supervisorctl] serverurl =unix:///tmp/supervisor.sock [include] files = relative/directory/*.ini
脚本配置 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 [program:belen] directory = /root/belen command = python belen.py autostart = true startsecs = 5 autorestart = true startretries = 3 user = root redirect_stderr = true stdout_logfile_maxbytes = 100 MB stdout_logfile_backups = 10 stdout_logfile = /root/belen/program.log
supervisorctl 命令简介 1 2 3 4 5 6 7 supervisorctl status supervisorctl stop Exchange supervisorctl start Exchange supervisorctl restart Exchange supervisorctl reload supervisorctl reread # 只更新配置文件 supervisorctl update # 重启配置文件修改过的程序