使用技巧
apt-get install supervisor
/etc/supervisor/conf.d
cat /etc/supervisor/conf.d/filebeat.conf
[program:filebeat]
directory=/data/filebeat
command=/data/filebeat/filebeat -c /data/filebeat/filebeat.yml
;user=ledou00
autorestart=true
redirect_stderr=true
stdout_logfile=/data/log/supervisord/filebeat.log
mkdir -p /data/log/supervisord
chmod -R 777 /data/log/supervisord*
#nginx
supervisorctl update
supervisorctl status
supervisorctl restart nginxsvr
启动 supervisor 服务
/etc/init.d/supervisor start
服务名:filebeat
查看单个任务状态: supervisorctl status 服务名
supervisorctl start 服务名
supervisorctl stop 服务名
supervisorctl restart 服务名
supervisorctl update
#
supervisorctl update
filebeat: added process group
supervisorctl start filebeat
filebeat: started
#添加模块
守护进程 php /data/wwwroot/fanbook-service-http-api/cmd/LogCenterController.php consume
1.进入目录 /etc/supervisor/conf.d
2.编辑配置文件 vi LogCenterController.conf (user 指定用户运行程序)
[program:LogCenterController]
directory=/data/wwwroot/fanbook-service-http-api/cmd
command=php /data/wwwroot/fanbook-service-http-api/cmd/LogCenterController.php consume
user=ubuntu
autorestart=true
redirect_stderr=true
stdout_logfile=/data/log/supervisord/LogCenterController.log
4.更新服务,默认是所有
supervisorctl update
filebeat: stopped
filebeat: updated process group
LogCenterController: added process group
更新指定服务
supervisorctl update LogCenterController
LogCenterController: stopped
LogCenterController: updated process group
5.检查状态
supervisorctl status
supervisorctl status LogCenterController
6.启动服务
supervisorctl start LogCenterController
#Supervisor只能管理非daemon的进程,也就是说Supervisor不能管理守护进程
#nginx 守护提示端口占用
#关闭 daemon off
cat /etc/supervisor/conf.d/nginxsvr.conf
[program:nginxsvr]
directory=/usr/local/nginx
;command=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
command=/usr/local/nginx/sbin/nginx -g 'daemon off;'
;user=ledou00
autorestart=true
redirect_stderr=true
stdout_logfile=/data/log/supervisord/nginxsvr.log
#错误
supervisorctl status
pkg_resources.DistributionNotFound: The 'supervisor==3.2.0' distribution was not found and is required by the application
是python版本引起的,编辑/usr/bin/supervisord /usr/bin/supervisorctl 将#!/usr/bin/python修改为#!/usr/bin/python2即可