• 第二章 Centos7下yum安装Supervisor3.4.0


    一、安装Supervisor

    [root@staging ~]# yum -y install supervisor
    

    二、编辑配置文件

    [root@staging ~]# vim /etc/supervisord.conf 
    ... ...
    [inet_http_server]   #开启web界面访问
    port=staging:12306	#这边主机名称+端口
    ... ...
    

    三、编写子进程配置文件

    [root@staging ~]# cat /etc/supervisord.d/frp.ini
    #项目名
    [program:frp]
    #脚本目录
    directory=/opt/frp_0.34.2_linux_amd64/
    #脚本执行命令
    command=/opt/frp_0.34.2_linux_amd64/frpc -c /opt/frp_0.34.2_linux_amd64/frpc.ini
    #supervisor启动的时候是否随着同时启动,默认True
    autostart=true
    #当程序exit的时候,这个program不会自动重启,默认unexpected,设置子进程挂掉后自动重启的情况,有三个选项,false,unexpected和true。如果为false的时候,无论什么情况下,都不会被重新启动,如果为unexpected,只有当进程的退出码不在下面的exitcodes里面定义的
    autorestart=true
    #这个选项是子进程启动多少秒之后,此时状态如果是running,则我们认为启动成功了。默认值为1
    startsecs=1
    #脚本运行的用户身份 
    user = root
    #日志输出 
    stderr_logfile=/tmp/blog_stderr.log 
    stdout_logfile=/tmp/blog_stdout.log 
    #把stderr重定向到stdout,默认 false
    redirect_stderr = true
    #stdout日志文件大小,默认 50MB
    stdout_logfile_maxbytes = 20MB
    #stdout日志文件备份数
    stdout_logfile_backups = 20
    

    四、启动supervisord

    #1.设置开机自启
    [root@staging ~]# systemctl enable supervisord.service
    Created symlink from /etc/systemd/system/multi-user.target.wants/supervisord.service to /usr/lib/systemd/system/supervisord.service.
    
    #2.启动supervisord
    [root@staging ~]# systemctl start supervisord.service
    
    #3.查看supervisord状态
    [root@staging ~]# systemctl status supervisord.service
    ● supervisord.service - Process Monitoring and Control Daemon
       Loaded: loaded (/usr/lib/systemd/system/supervisord.service; enabled; vendor preset: disabled)
       Active: active (running) since Thu 2021-11-18 12:29:03 CST; 48s ago
      Process: 9817 ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf (code=exited, status=0/SUCCESS)
     Main PID: 9821 (supervisord)
        Tasks: 1
       CGroup: /system.slice/supervisord.service
               └─9821 /usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf
    
    Nov 18 12:29:03 staging systemd[1]: Starting Process Monitoring and Control Daemon...
    Nov 18 12:29:03 staging systemd[1]: Started Process Monitoring and Control Daemon.
    

    五、验证supervisor

    #1.查看所有进程的状态
    [root@staging ~]# supervisorctl status
    frp                              RUNNING   pid 6890, uptime 0:00:06
    
    #2.web界面查看(此处内网服务器部署,故没有设置密码,暴露公网建议加密)
    

  • 相关阅读:
    git
    fragment
    Builder模式
    代码混淆
    android studio快捷键
    小知识点
    angular组件使用
    英语摘要2019-6-4
    英语笔记2019-4-3
    搭建Eureka注册中心时遇到的问题
  • 原文地址:https://www.cnblogs.com/jhno1/p/15572231.html
Copyright © 2020-2023  润新知