supervisor安装文档

supervisor安装

  1. 安装
    # centos自带的源无supervisor,因此安装扩展源
    yum install -y epel-release
    yum install supervisor -y
    
  2. 管理
    # 启动
    systemctl status supervisord.service
    # 重启
    systemctl restart supervisord.service
    # 停止
    systemctl stop supervisord.service
    # 状态
    systemctl status supervisord.service
    # 开机启动
    systemctl enable supervisord.service
    # 取消开机启动
    systemctl disable supervisord.service
    
  3. 命令
    supervisorctl --help
    
  4. 默认配置修改
    # 编辑配置
    vim /etc/supervisord.conf
    # 启动web服务(去掉注释,修改用户名及密码)
    [inet_http_server]         ; inet (TCP) server disabled by default
    port=0.0.0.0:9001        ; (ip_address:port specifier, *:port for all iface)
    username=user              ; (default is no username (open server))
    password=123               ; (default is no password (open server))
    # 保存退出后,重启
    systemctl restart supervisord.service
    # 修改防火墙允许9001端口访问 (如果使用防火墙)
    firewall-cmd --permanent --zone=public --add-port=9001/tcp
    firewall-cmd --reload
    
  5. 增加一个测试程序
    vim /etc/supervisord.d/test.ini
    # 写入
    [program:test]
    command=/usr/local/redis-4.0.8/src/redis-server /usr/local/redis-4.0.8/redis.conf
    # 保存退出后重启
    systemctl restart supervisord.service
    
  6. 其他配置

    参考官网: http://www.supervisord.org/configuration.html#program-x-section-example

    如程序:

    [program:cat]
    command=/bin/cat
    process_name=%(program_name)s
    numprocs=1
    directory=/tmp
    umask=022
    priority=999
    autostart=true
    autorestart=unexpected
    startsecs=10
    startretries=3
    exitcodes=0
    stopsignal=TERM
    stopwaitsecs=10
    stopasgroup=false
    killasgroup=false
    user=chrism
    redirect_stderr=false
    stdout_logfile=/a/path
    stdout_logfile_maxbytes=1MB
    stdout_logfile_backups=10
    stdout_capture_maxbytes=1MB
    stdout_events_enabled=false
    stderr_logfile=/a/path
    stderr_logfile_maxbytes=1MB
    stderr_logfile_backups=10
    stderr_capture_maxbytes=1MB
    stderr_events_enabled=false
    environment=A="1",B="2"
    serverurl=AUTO
    

发表评论

电子邮件地址不会被公开。 必填项已用*标注