supervisor 模块

本文介绍了Supervisor,一个基于Python的进程管理工具,用于轻松启动、关闭和重启用户定义的进程。它包括服务端和客户端组件,提供web界面以清晰查看进程状态和日志。内容涵盖Supervisor的安装配置、使用说明和示例,展示了如何管理Python进程。
摘要由CSDN通过智能技术生成
一、简介
  • (1) 基于python编写,安装方便
  • (2) 进程管理工具,可以很方便的对用户定义的进程进行启动,关闭,重启,并且对意外关闭的进程进行重启 ,只需要简单的配置一下即可,且有web端,状态、日志查看清晰明了。
  • (3) 组成部分
    • supervisord[服务端,要通过这个来启动它]
    • supervisorctl[客户端,可以来执行stop等命令]
  • (4) 官方文档地址:http://supervisord.org/
二、安装及配置

(1)安装

# pip 安装
pip3 install supervisor

# yum 安装
yum install supervisor

# 源码安装
cd /usr/local/src
wget https://pypi.python.org/packages/7b/17/88adf8cb25f80e2bc0d18e094fcd7ab300632ea00b601cbbbb84c2419eae/supervisor-3.3.2.tar.gz
tar -zxvf supervisor-3.3.2.tar.gz
cd supervisor-3.3.2
python setup.py install  # 本地python版本为python2.7
					    # python2.7 setup.py install 
    					# 本地python版本为python3以上
						# 目前superevisor还不支持python3.x版本

(2)配置

# 生成配置文件
echo_supervisord_conf > /etc/supervisord.conf

# 启动
supervisord -c /etc/supervisord.conf

查看supervisord是否在运行:

ps aux |grep supervisord
三、使用说明

(1)查看默认配置

echo_supervisord_conf

输出如下:

; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Notes:
;  - Shell expansion ("~" or "$HOME") is not supported.  Environment
;    variables can be expanded using this syntax: "%(ENV_HOME)s".
;  - Quotes around values are not supported, except in the case of
;    the environment= options as shown below.
;  - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
;  - Command will be truncated if it looks like a config file comment, e.g.
;    "command=bash -c 'foo ; bar'" will truncate to "command=bash -c 'foo ".

[unix_http_server]
file=/usr/local/var/run/supervisor.sock   ; the path to the socket file
;chmod=0700                 ; socket file mode (default 0700)
;chown=nobody:nogroup       ; socket file uid:gid owner
;username=user              ; default is no username (open server)
;password=123               ; default is no password (open server)

;[inet_http_server]         ; inet (TCP) server disabled by default
;port=127.0.0.1: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)

[supervisord]
logfile=/usr/local/var/log/supervisord.log ; main log file
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值