CentOS 7 安装 supervisord(亲测)

本贴最后更新于 2320 天前,其中的信息可能已经时过境迁

废话少说,直蹦主题!

1、安装必要的包:

yum install python-setuptools easy_install pip

2、安装 supervisor

pip install supervisor

3、生成 supervisor 配置文件

echo_supervisord_conf > /etc/supervisord.conf

4、新建自定义进程脚本目录

mkdir /etc/supervisord.d/

5、修改 supervisor 配置文件/etc/supervisor.conf,方便管理自定义进程

[include] files = /etc/supervisord.d/*.conf

6、创建 supervisord 启动脚本

/etc/init.d/supervisord
#!/bin/sh # # /etc/init.d/supervisord # # Supervisor is a client/server system that # allows its users to monitor and control a # number of processes on UNIX-like operating # systems. # # chkconfig: - 64 36 # description: Supervisor Server # processname: supervisord # Source init functions . /etc/rc.d/init.d/functions prog="supervisord" prefix="/usr/local" exec_prefix="${prefix}" prog_bin="${exec_prefix}/bin/supervisord" PIDFILE="/var/run/$prog.pid" start() { echo -n $"Starting $prog: " ###注意下面这一行一定得有-c /etc/supervisord.conf 不然修改了配置文件根本不生效! daemon $prog_bin -c /etc/supervisord.conf --pidfile $PIDFILE [ -f $PIDFILE ] && success $"$prog startup" || failure $"$prog startup" echo } stop() { echo -n $"Shutting down $prog: " [ -f $PIDFILE ] && killproc $prog || success $"$prog shutdown" echo } case "$1" in start) start ;; stop) stop ;; status) status $prog ;; restart) stop start ;; *) echo "Usage: $0 {start|stop|restart|status}" ;; esac

7、supervisor 加入开机启动

chmod +x /etc/init.d/supervisord chkconfig --add supervisord chkconfig supervisord on service supervisord start

8、supervisor 最基本使用方法

创建一个后台进程执行脚本:

vi /etc/supervisord.d/test.conf
[program:test] command=tail -f /etc/supervisord.conf ;常驻后台的命令 autostart=true ;是否随supervisor启动 autorestart=true ;是否在挂了之后重启,意外关闭后会重启,比如kill掉! startretries=3 ;启动尝试次数 stderr_logfile=/tmp/test.err.log ;标准输出的位置 stdout_logfile=/tmp/test.out.log ;标准错误输出的位置

9、重启 supervisor

/etc/init.d/supervisord restart
  • B3log

    B3log 是一个开源组织,名字来源于“Bulletin Board Blog”缩写,目标是将独立博客与论坛结合,形成一种新的网络社区体验,详细请看 B3log 构思。目前 B3log 已经开源了多款产品:SymSoloVditor思源笔记

    1063 引用 • 3455 回帖 • 162 关注
  • supervisor
    6 引用 • 1 回帖
  • supervisord
    1 引用

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...