• Centos7.x 安装 Supervisord


    【环境】

    系统:Centos 7.3

    软件:supervisord

    【安装Supervisord】

    yum install epel-release
    yum install -y supervisor

    【设置开启自启】

    systemctl enable supervisord

    【Supervisord管理命令】

    systemctl stop supervisord
    systemctl start supervisord
    systemctl status supervisord
    systemctl reload supervisord
    systemctl restart supervisord

    【修改配置文件,使Supervisord可以在web端显示】

    vim /etc/supervisord.conf

    #取消10-13行注释,前面数字是行号
    10 [inet_http_server]         ; inet (TCP) server disabled by default
    11 port=127.0.0.1:9001        ; (ip_address:port specifier, *:port for all iface)
    12 username=user              ; (default is no username (open server))
    13 password=123               ; (default is no password (open server))

    【监控】

    然后设置监控文件以及脚本等

    比如我们创建一个死循环,让脚本来监控,这里拿python来说吧

    在home目录下创建一个while循环的py文件

    vim /home/test.py

    while True:
    
       print(100)

    这个文件一直打印100,如果不强制终止,则不会停止,接下来配置supervisord。我们可以通过配置文件最后一行看到

    cat /etc/supervisord.conf

    [include]
    files = supervisord.d/*.ini

    也就是说,我们所有的配置文件都保存在这个目录下,以.ini格式命名保存的,可以自行修改地址,但不要修改后缀,那我们来创建supervisor文件吧

    【创建Supervisord文件】

    vim /etc/supervisord.d/python.ini

    [program:python]   #这里的python就是我们显示在web前端以及终端的监控名称
    command=python /home/test.py  #我们要监控的文件地址
    autostart=true
    autorestart=true
    startsecs=1
    startretries=3
    redirect_stderr=true
    stdout_logfile=/etc/supervisord.log/access_python.log   #日志地址,可自行配置目录
    stderr_logfile=/etc/supervisord.log/error_python.log     #日志地址,可自行配置目录

    【启动Supervisord】

    systemctl start supervisord
    查看是否启动
    systemctl status supervisord

    注:如果启动成功后无法登陆web端,则允许9001端口通过防火墙或者关闭防火墙,关闭selinux,把supervisord.conf中的port=127.0.0.1:9001中的127.0.0.1修改成IP地址重启服务进行访问

    【Web端登陆】

     【登陆成功】

    登陆之后,会出现如下界面,可以对该文件进行一些操作,打开、停止、查看日志、清除日志

  • 相关阅读:
    POJ3233 构造子矩阵+矩阵快速幂
    HDU4565-数学推导求递推公式+矩阵快速幂
    记录一个状压DP用到的骚操作
    POJ1273 最大流模板
    图论复习...
    2017-7 实训经验贴
    Polya定理应用实例
    直线,椭圆,三角形,折线分割平面问题
    hdu4801 PocketCube 2阶魔方
    1256:献给阿尔吉侬的花束
  • 原文地址:https://www.cnblogs.com/willamwang/p/11447404.html
Copyright © 2020-2023  润新知