分享

你不知道的CS模式的进程管理工具,状态监测、项目启停一目了然!

 Python集中营 2022-10-10 发布于甘肃

Supervisor安装

 1'''
2环境:Centos7
3安装wget:yum install wget
4下载Supervisor源码包
5'''

6# [root@localhost software]# yum install wget
7# 已加载插件:fastestmirror
8# Loading mirror speeds from cached hostfile
9#  * base: mirror.lzu.edu.cn
10#  * extras: mirror.lzu.edu.cn
11#  * updates: mirrors.163.com
12# 正在解决依赖关系
13# --> 正在检查事务
14# ---> 软件包 wget.x86_64.0.1.14-18.el7_6.1 将被 安装
15
16
17# [root@localhost software]# wget https://files./packages/d3/7f/c780b7471ba0ff4548967a9f7a8b0bfce222c3a496c3dfad0164172222b0/supervisor-4.2.2.tar.gz
18# --2021-09-24 15:45:28--  https://files./packages/d3/7f/c780b7471ba0ff4548967a9f7a8b0bfce222c3a496c3dfad0164172222b0/supervisor-4.2.2.tar.gz
19# 正在解析主机 files. (files.)... 151.101.77.63, 2a04:4e42:12::319
20# 正在连接 files. (files.)|151.101.77.63|:443... 已连接。
21# 已发出 HTTP 请求,正在等待回应... 200 OK
22# 长度:463657 (453K) [application/x-tar]
23# 正在保存至: “supervisor-4.2.2.tar.gz”

Supervisor配置

  1'''
21、解压源码包
3tar -zxvf supervisor-4.2.2.tar.gz
4'''

5
6# root@localhost software]# tar -zxvf supervisor-4.2.2.tar.gz
7# supervisor-4.2.2/
8# supervisor-4.2.2/CHANGES.rst
9# supervisor-4.2.2/COPYRIGHT.txt
10
11'''
122、安装python支持
13yum install python-setuptools
14'''

15
16# [root@localhost supervisor-4.2.2]# yum install python-setuptools
17# 已加载插件:fastestmirror
18# Loading mirror speeds from cached hostfile
19
20'''
213、编译源码包
22python setup.py install
23'''

24
25# [root@localhost supervisor-4.2.2]# python setup.py install
26# running install
27# running bdist_egg
28# running egg_info
29# writing requirements to supervisor.egg-info/requires.txt
30
31'''
324、编译后删除其他多余文件、除了build、dist两个文件夹其他都是多余的
33'''

34
35# [root@localhost supervisor-4.2.2]# ll
36# 总用量 0
37# drwxr-xr-x. 4 root root 43 9月  24 15:51 build
38# drwxr-xr-x. 2 root root 40 9月  24 15:51 dist
39
40'''
415、创建配置文件、编辑配置文件、赋予文件权限
42'''

43
44# echo_supervisord_conf > /usr/etc/supervisord.conf
45
46# [root@localhost supervisor-4.2.2]# vi  /usr/etc/supervisord.conf
47
48# chmod 777 /usr/etc/supervisord.conf
49
50# [root@localhost supervisor-4.2.2]# mkdir config
51
52# /usr/etc/supervisord.conf文件主要配置两个关键项
53
54# [supervisord]
55# user=普通用户名称            ; setuid to this UNIX account at startup; recommended if root
56
57# [include]
58# files = /software/supervisor-4.2.2/config   # 这个是以后的项目路径
59
60'''
616、查看版本
62'''

63
64# [root@localhost supervisor-4.2.2]# supervisord -v
65# 4.2.2
66
67'''
687、解决python2.7.sock报错的问题
69'''

70
71# [root@localhost supervisor-4.2.2]# /usr/bin/python2 /usr/bin/supervisord -c /usr/etc/supervisord.conf
72
73'''
748、更新配置
75'''

76
77# supervisorctl update
78
79'''
809、配置一个程序项目配置
81注意:这里使用hello_world只是作为一个说明,一般项目指的都是一直运行的进程服务,比如:redis、tomcat、nginx等等。
82'''

83# [root@localhost config]# vi hello_world.config
84
85# [program:hello_world]
86# command=/usr/bin/python2 /software/supervisor-4.2.2/hello_world.py
87# priority=998
88# autostart=true
89# autorestart=true
90# startsecs=60
91# startretries=3
92# stopsignal=TERM
93# stopwaitsecs=10
94# user=root
95# stdout_logfile=/software/supervisor-4.2.2/logs/hello_world.log
96# stdout_logfile_maxbytes=100MB
97# stdout_logfile_backups=10
98# stdout_capture_maxbytes=1MB
99# stderr_logfile=/software/supervisor-4.2.2/logs/hello_world.log
100# stderr_logfile_maxbytes=100MB
101# stderr_logfile_backups=10
102# stderr_capture_maxbytes=1MB
103
104'''
10510、创建hello_world项目
106注意:这里使用hello_world只是作为一个说明,一般项目指的都是一直运行的进程服务,比如:redis、tomcat、nginx等等。
107'''

108
109# [root@localhost supervisor-4.2.2]# vi hello_world.py
110
111# # -*- coding:utf-8 -*-
112# print "我是hello_world程序"
113
114'''
11511、重启配置的所有程序
116'''

117
118# [root@localhost supervisor-4.2.2]# supervisorctl reload
119# Restarted supervisord
120
121'''
12212、启动或停止某个项目
123注意:这里使用hello_world只是作为一个说明,一般项目指的都是一直运行的进程服务,比如:redis、tomcat、nginx等等。
124'''

125
126# supervisorctl start 项目名称
127# supervisorctl start hello_world
128
129# supervisorctl stop 项目名称
130
131# supervisorctl stop hello_world

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多