本篇笔记记录了CentOS6.9中安装Supervisor管理后台进程,并将Supervisord加入服务,设置开机启动,通过service管理的过程
创建并进入源码存放目录
mkdir -p /usr/local/src
cd /usr/local/src
下载并解压supervisor源码
wget -c https://files.pythonhosted.org/packages/ba/65/92575a8757ed576beaee59251f64a3287bde82bdc03964b89df9e1d29e1b/supervisor-3.3.5.tar.gz
tar -zxvf supervisor-3.3.5.tar.gz
cd supervisor-3.3.5
安装supervisor
python setup.py install
如果出现错误:ImportError: No module named setuptools
安装python-setuptoolsyum install python-setuptools
下面的结果表示supervisor安装成功
Installed /usr/lib/python2.6/site-packages/meld3-1.0.2-py2.6.egg
Finished processing dependencies for supervisor==3.3.5
创建supervisord.d目录
mkdir /etc/supervisord.d
创建并编辑配置文件
echo_supervisord_conf > /etc/supervisord.conf
vim /etc/supervisord.conf
修改以下几处
file=/var/run/supervisor.sock
logfile=/var/log/supervisord.log
pidfile=/var/run/supervisord.pid
serverurl=unix:///var/run/supervisor.sock
[include]
files = supervisord.d/*.conf
启动supervisord
supervisord -c /etc/supervisord.conf
查看进程
ps aux | grep supervisord
root 3110 0.0 1.0 196612 10816 ? Ss 20:12 0:00 /usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf
root 3504 0.0 0.0 103336 908 pts/0 S+ 20:19 0:00 grep supervisord
kill 3110
创建启动脚本
vim /etc/init.d/supervisord
写入如下配置
#!/bin/bash
#
# supervisord This scripts turns supervisord on
#
# Author: Mike McGrath <mmcgrath@redhat.com> (based off yumupdatesd)
# Jason Koppe <jkoppe@indeed.com> adjusted to read sysconfig,
# use supervisord tools to start/stop, conditionally wait
# for child processes to shutdown, and startup later
# Mikhail Mingalev <mingalevme@gmail.com> Merged
# redhat-init-jkoppe and redhat-sysconfig-jkoppe, and
# made the script "simple customizable".
# Brendan Maguire <maguire.brendan@gmail.com> Added OPTIONS to
# SUPERVISORCTL status call
#
# chkconfig: 345 83 04
#
# description: supervisor is a process control utility. It has a web based
# xmlrpc interface as well as a few other nifty features.
# Script was originally written by Jason Koppe <jkoppe@indeed.com>.
#
# source function library
. /etc/rc.d/init.d/functions
set -a
PREFIX=/usr
SUPERVISORD