Mac下Supervisor进程监控管理工具的安装与配置

yipeiwu_com6年前Python基础

Supervisor 是一个类 unix 操作系统下的进程监控管理工具。

安装 Supervisor

Supervisor 是由 Python 写成,可用 Python 的包安装管理工具 pip(Python Package Index) 直接安装:

复制代码 代码如下:

sudo pip install supervisor

配置 Supervisor

Supervisor 的配置文件命名为 supervisord.conf,它为 supervisord(Supervisor 的主服务命令) 和 supervisorctl(Supervisor 的监控管理命令) 提供配置选项设置。 Supervisor 并不规定配置文件 supervisord.conf 的存放位置,Supervisor 服务启动的时候默认会在:

复制代码 代码如下:

$CWD/supervisord.conf
$CWD/etc/supervisord.conf
/etc/supervisord.conf

这几个目录位置查找配置文件 supervisord.conf。Supervisor 也提供参数 "-c" 来指定配置文件的目录路径。

在终端输入 "echo_supervisord_conf" 命令可查看 Supervisor 的默认配置的内容。

生成一份默认的配置文件:

复制代码 代码如下:

echo_supervisord_conf > /etc/supervisord.conf

这里有选择的设置了一些配置,基本够用,配置如下:

复制代码 代码如下:

[inet_http_server]
port = 127.0.0.1:9001
username = dhq
password = 123456
 
[unix_http_server]
file = /tmp/supervisor.sock
chmod = 0700
 
[supervisord]
logfile = /Users/dengjoe/.supervisor/supervisord.log
logfile_maxbytes = 50MB
logfile_backups=10
loglevel = info
pidfile = /tmp/supervisord.pid
nodaemon = False
minfds = 1024
minprocs = 200
umask = 022
identifier = supervisor
directory = /tmp
nocleanup = true
childlogdir = /tmp
 
[supervisorctl]
serverurl = unix:///tmp/supervisor.sock
 
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
 
 
 
[program:shadowsocks]
directory = /Users/dengjoe/shadowsocks
command = /usr/bin/python /Users/dengjoe/shadowsocks/local.py
autostart = true
autorestart = true

启动 Supervisor

复制代码 代码如下:

supervisord -c /etc/supervisord.conf

参数 "-c" 表示指定 Supervisor 配置文件的路径

把 supervisord 加入系统启动服务

复制代码 代码如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>KeepAlive</key>
    <dict>
        <key>SuccessfulExit</key>
        <false/>
    </dict>
    <key>Label</key>
    <string>dengjoe.supervisord</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/supervisord</string>
        <string>-n</string>
        <string>-c</string>
        <string>/etc/supervisord.conf</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

启动 Supervisor 服务:

复制代码 代码如下:

launchctl load ~/Library/LaunchAgents/dengjoe.supervisord.plist

supervisorctl 监控命令

supervisorctl 是 Supervisor 自带的后台进程控制工具,下面是该命令的一些用法:

启动应用:

复制代码 代码如下:

supervisorctl start program

重新读取配置:

复制代码 代码如下:

supervisorctl update

相关文章

使用pyinstaller逆向.pyc文件

使用pyinstaller逆向.pyc文件

搭建python环境 1.百度搜索python3.7下载,找到官网下载安装包,运行安装包并配置环境变量。 2.这里一定要安装python3.7版本的,我之前安装python...

python+selenium select下拉选择框定位处理方法

一、前言 总结一下python+selenium select下拉选择框定位处理的两种方式,以备后续使用时查询; 二、直接定位(XPath) 使用Firebug找到需要定位到的元素,直接...

使用python PIL库实现简单验证码的去噪方法步骤

使用python PIL库实现简单验证码的去噪方法步骤

字符型图片验证码识别完整过程及Python实现的博主,我的大部分知识点都是从他那里学来的。 想要识别验证码,收集足够多的样本后,首先要做的就是对验证码原始图片进行处理,对验证码识别分类之...

改进Django中的表单的简单方法

首先,search()视图对于空字符串的处理相当薄弱——仅显示一条”Please submit a search term.”的提示信息。 若用户要重新填写表单必须自行点击“后退”按钮,...

Python3下错误AttributeError: ‘dict’ object has no attribute’iteritems‘的分析与解决

引言 目前Python2和Python3存在版本上的不兼容性,这里将列举dict中的问题之一。下面话不多说,来看看详细的介绍: 1. Python 2  vs python 3...