CentOS6.9安装Supervisor管理后台进程并设置开机启动

本文详细介绍了在CentOS6.9上安装Supervisor以管理后台进程,包括添加服务、设置开机启动,以及使用service进行管理的步骤。主要内容包括安装源码、配置文件修改、创建启动脚本、加入服务、设置权限和测试进程管理。
摘要由CSDN通过智能技术生成

本篇笔记记录了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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值