博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
supervisor的使用简介
阅读量:7019 次
发布时间:2019-06-28

本文共 2954 字,大约阅读时间需要 9 分钟。

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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
1、安装
wget https:
//bitbucket
.org
/pypa/setuptools/raw/bootstrap/ez_setup
.py -O - | python
easy_install supervisor
 
或者
yum 
install 
python-pip
pip 
install 
supervisor
 
 
2、配置文件:
# echo_supervisord_conf > /etc/supervisord.conf \
&& 
mkdir 
/etc/supervisor
.d \
&& 
/usr/bin/echo_supervisord_conf 
>
/etc/supervisord
.conf  \
&& 
echo 
-e 
'[include]\nfiles=/etc/supervisor.d/*.ini' 
>>
/etc/supervisord
.conf \
&& 
grep 
^[^\;] 
/etc/supervisord
.conf
 
 
 
3、启动supervisord服务:
# whereis supervisord
supervisord: 
/etc/supervisord
.conf 
/usr/local/bin/supervisord
# /usr/local/bin/supervisord -c /etc/supervisord.conf
 
并增加到开机启动
/etc/rc
.
local
# echo '/usr/local/bin/supervisord -c /etc/supervisord.conf' >>/etc/rc.local
 
4、配置服务
# cd /etc/supervisor.d
# cat sshd.ini
[program:sshd]
command
=
/usr/sbin/sshd 
-D
 
# cat test.ini
[program:
test
]
command
=
/usr/bin/php  
xxx.php
process_name=%(program_name)s_%(process_num)02d
numprocs=5
user=nobody
 
# cat uwsgi.ini
[program:uwsgi]
command
=
/usr/local/bin/uwsgi 
--http 127.0.0.1:8090 --chdir 
/opt/test-django/www 
--module www.wsgi >
/var/log/nginx/uwsgi
.log 2>&1
 
重新加载supervisord服务:
# supervisorctl reload
Restarted supervisord
 
验证
# supervisorctl status
uwsgi                            RUNNING   pid 15041, uptime 0:00:17
# ss -antp src :8090
State       Recv-Q Send-Q                     Local Address:Port                       Peer Address:Port
LISTEN      0      100                            127.0.0.1:8090                                  *:*      
users
:((
"uwsgi"
,15041,4),(
"uwsgi"
,15042,4))
 
调整user1增加
sudo
的权限:
user1 ALL=NOPASSWD: 
/usr/bin/supervisorctl
然后通过这样的方式来管理:
sudo 
supervisorctl status|stop|start|restart
 
 
5、新增一个服务的正确姿势
总结下来就2个指令:
supervisorctl reread
supervisorctl update
 
实例:
[root@tvm001 supervisor.d]
# pwd
/etc/supervisor
.d
 
[root@tvm001 supervisor.d]
# ls
gogogo.ini  uwsgi_asset.ini  uwsgi.ini
 
[root@tvm001 supervisor.d]
# cat gogogo.ini
[program:gogogo]
command
=
/bin/cat
autostart=
true
autorestart=
true
stdout_logfile=
/tmp/gogogo
.stdout.log
stderr_logfile=
/tmp/gogogo
.stderr.log
 
[root@tvm001 supervisor.d]
# supervisorctl status
uwsgi                            RUNNING   pid 26248, uptime 5:13:02
uwsgi_asset                      RUNNING   pid 26247, uptime 5:13:02
[root@tvm001 supervisor.d]
# supervisorctl reread
gogogo: available
[root@tvm001 supervisor.d]
# supervisorctl status
uwsgi                            RUNNING   pid 26248, uptime 5:13:12
uwsgi_asset                      RUNNING   pid 26247, uptime 5:13:12
[root@tvm001 supervisor.d]
# supervisorctl update
gogogo: added process group
[root@tvm001 supervisor.d]
# supervisorctl status
gogogo                           RUNNING   pid 27147, uptime 0:00:04
uwsgi                            RUNNING   pid 26248, uptime 5:13:25
uwsgi_asset                      RUNNING   pid 26247, uptime 5:13:25
[root@tvm001 supervisor.d]
#
 
 
ZYXW、参考
1、doc
http:
//www
.supervisord.org
/running
.html
#supervisorctl-actions

本文转自 pcnk 51CTO博客,原文链接:http://blog.51cto.com/nosmoking/1595238,如需转载请自行联系原作者

你可能感兴趣的文章
929. Unique Email Address - LeetCode
查看>>
Cisco 3560 级联端口不通的原因
查看>>
Zend Studio 无法打开的解决办法
查看>>
IEEE 802.3标准
查看>>
[安装程序]HDDScan(硬盘坏道检测工具) 3.3[详细检测你的硬盘信息]
查看>>
我的友情链接
查看>>
Linux基础笔记用户管理
查看>>
用Java集合中的Collections.sort方法对list排序的两种方法
查看>>
利用mysql的注射点得到更多mysql的信息
查看>>
好程序员web前端分享CSS基础篇
查看>>
粘性(sticky)mac地址
查看>>
error: no valid connection
查看>>
一句话说明数组和集合的区别
查看>>
漫画:混乱的标记语言XHTML2HTML5
查看>>
Mac环境下svn的使用
查看>>
Lync开发实例2—添加自定义菜单
查看>>
安卓系统4.4 KK APP无法选择外置存储路径的的解决办法
查看>>
centos6.6安装web版GIT --gogs
查看>>
1.9、Bootstrap V4自学之路------起步---JAVASCRIPT
查看>>
有理想的程序员必须知道的15件事
查看>>