1.安装
1
|
yum -y
install
supervisor
|
2.生成配置文件,默认不存在路径自己选择
1
|
echo_supervisord_conf >
/etc/supervisord
.conf
|
3.配置web管理界面 vi
1
2
3
4
5
6
|
vi
/etc/supervisord
.conf
#默认前面是;注释打开即可
[inet_http_server] ; inet (TCP) server disabled by default
port=192.168.56.15:9001 ; (ip_address:port specifier, *:port
for
all iface)
username=user ; (default is no username (
open
server))
password=123 ; (default is no password (
open
server))
|
4.启动supervisor
1
|
systemctl start supervisord
|
5.输入用户名和密码进入管理web界面 没有程序管理
1
|
<br>
|
6.supervisor 基本配置
1
2
3
4
5
6
7
8
9
|
[supervisord]
logfile=
/tmp/supervisord
.log ;日志文件,默认是 $CWD
/supervisord
.log
logfile_maxbytes=50MB ;日志文件大小,超出会rotate,默认 50MB,如果设成0,表示不限制大小
logfile_backups=10 ;日志文件保留备份数量默认10,设为0表示不备份
loglevel=info ;日志级别,默认info,其它: debug,warn,trace
pidfile=
/tmp/supervisord
.pid ;pid 文件
nodaemon=
false
;是否在前台启动,默认是
false
,即以 daemon 的方式启动
minfds=1024 ;可以打开的文件描述符的最小值,默认 1024
minprocs=200 ;可以打开的进程数的最小值,默认 200
|
7.supervisor添加程序的参数介绍
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[program:xx]
command=/opt/apache-tomcat/bin/catalina.sh run ; 程序启动命令
autostart=
true
; 在supervisord启动的时候也自动启动
startsecs=10 ; 启动10秒后没有异常退出,就表示进程正常启动了,默认为1秒
autorestart=
true
; 程序退出后自动重启,可选值:[unexpected,
true
,
false
],默认为unexpected,表示进程意外杀死后才重启
startretries=3 ; 启动失败自动重试次数,默认是3
user=tomcat ; 用哪个用户启动进程,默认是root
priority=999 ; 进程启动优先级,默认999,值小的优先启动
redirect_stderr=
true
; 把stderr重定向到stdout,默认
false
stdout_logfile_maxbytes=20MB ; stdout 日志文件大小,默认50MB
stdout_logfile_backups = 20 ; stdout 日志文件备份数,默认是10
; stdout 日志文件,需要注意当指定目录不存在时无法正常启动,所以需要手动创建目录(supervisord 会自动创建日志文件)
stdout_logfile=/opt/apache-tomcat/logs/catalina.out
stopasgroup=
false
;默认为
false
,进程被杀死时,是否向这个进程组发送stop信号,包括子进程
killasgroup=
false
;默认为
false
,向进程组发送kill信号,包括子进程进程数的最小值,默认 200
|
8.添加nginx 服务监控
1
2
3
4
5
6
7
8
9
10
|
[program:nginx]
command
=nginx
process_name=%(program_name)s
autostart=
true
autorestart=
true
startretries=10
exitcodes=0
stopsignal=KILL
stopwaitsecs=10
redirect_stderr=
true
|
9.1启动supervisor,配置nginx
要在配置文件中加daemon off;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
[root@localhost run]
# ps -ef|grep nginx
root 7262 7258 2 04:46 ? 00:00:00 nginx: master process nginx
nginx 7263 7262 0 04:46 ? 00:00:00 nginx: worker process
nginx 7264 7262 0 04:46 ? 00:00:00 nginx: worker process
root 7277 2404 0 04:46 pts
/1
00:00:00
grep
--color=auto nginx
[root@localhost run]
# ps -ef|grep nginx |awk '{print $2}'
7262
7263
7264
7312
[root@localhost run]
# kill -9 `ps -ef|grep nginx |awk '{print $2}'`
-
bash
:
kill
: (7334) - No such process
[root@localhost run]
# ps -ef|grep nginx
root 7339 7258 3 04:46 ? 00:00:00 nginx: master process nginx
nginx 7340 7339 0 04:46 ? 00:00:00 nginx: worker process
nginx 7341 7339 0 04:46 ? 00:00:00 nginx: worker process
root 7349 2404 0 04:46 pts
/1
00:00:00
grep
--color=auto nginx
[root@localhost run]
# ps -ef|grep nginx
root 7339 7258 2 04:46 ? 00:00:00 nginx: master process nginx
nginx 7340 7339 0 04:46 ? 00:00:00 nginx: worker process
nginx 7341 7339 0 04:46 ? 00:00:00 nginx: worker process
root 7354 2404 0 04:46 pts
/1
00:00:00
grep
--color=auto nginx
[root@localhost run]
#
|
10.查看首台
本文转自 小小三郎1 51CTO博客,原文链接:http://blog.51cto.com/wsxxsl/1950932,如需转载请自行联系原作者