supervisor+inotify监控管理nginx项目

安装supervisor

yum install epel-release -y
yum install supervisor inotify-tools -y
chkconfig --add supervisord
chkconfig --level 235 supervisord on

/etc/supervisord.conf增加的内容如下

[program:inotifywait]
command="/opt/inotifywait.sh"
numprocs=1


/opt/inotifywait.sh的配置内容如下:

cat  /opt/inotifywait.sh
#!/bin/bash
inotifywait -mrqe delete,create /opt/nginx | while read file
do nginx -s reload
echo `date`>>/tmp/rsync.log
done

supervisorctl常用命令

supervisorctl reload  //重载supervisor
supervisorctl update //更新supervisor
supervisorctl status //查看状态
supervisorctl update //更新新的配置到supervisord
supervisorctl start [all]|[x]     //启动所有/指定的程序进程
supervisorctl stop [all]|[x]      //关闭所有/指定的程序进程
supervisord          //启动supervisor
supervisord -c supervisor.conf   //通过配置文件启动supervisor
supervisorctl start test  //开启test服务