zoukankan      html  css  js  c++  java
  • centos7 安装supervisor

    1. 安装必要的包:

    yum install python-setuptools
    easy_install pip
    pip install supervisor
    echo_supervisord_conf > /etc/supervisord.conf
    或者
    yum install -y supervisor

      

    2. 新建自定义进程脚本目录

    mkdir /etc/supervisord.d/
    

      

    3. 创建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
    

      

    4. supervisor加入开机启动

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

      

    5. 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        ;标准错误输出的位置
    

      

    7. 重启supervisor

    /etc/init.d/supervisord restart
    或者
    service supervisord start
    
    
    客户端命令
    supervisorctl (start|stop|restart|status)
    

      

  • 相关阅读:
    QuickClip—界面原型设计
    视频剪辑软件调研分析及使用感受——后附作品地址
    《梦断代码》——理智上悲观,意志上乐观
    《人月神话》—危险的神话
    zabbix监控交换机
    linux常用经典命令
    zabbix使用tokudb引擎替换innodb引擎
    CART分类回归树算法
    朴素贝叶斯分类算法
    分布式系统阅读笔记(十三)-----命名服务
  • 原文地址:https://www.cnblogs.com/freespider/p/12659984.html
Copyright © 2011-2022 走看看