supervisor的使用简介

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,如需转载请自行联系原作者

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值