nginx通过Supervisor实现守护进程

  • 部署supervisor服务

    # easy_install的方式
    yum install -y python-setuptools
    easy_install supervisor
    echo_supervisord_conf >/etc/supervisord.conf
    
  • 配置supervisord.conf

    # 修改supervisord.conf行尾
    
    [include]
    files = /etc/supervisor/*.conf
    
    # web界面显示
    [inet_http_server]
    port=IP:9001
    
    # 启动
    supervisord -c supervisord.conf
    
    # 创建目录
    mkdir -p /etc/supervisor
    
    
  • 配置nginx.conf文件

    # vim /etc/supervisor/nginx.conf
    [program: nginx]
    command=/data/nginx/sbin/nginx  -g 'daemon off;'  # 修改自己的路径
    autorestart=true ;
    autostart=true ;
    stderr_logfile=/var/log/error.log ;
    stdout_logfile=/var/log/stdout.log ;
    environment=ASPNETCORE_ENVIRONMENT=Production ;
    user=root ;
    stopsignal=INT
    startsecs=10 ;
    startretries=5 ;
    stopasgroup=true
    
    # 重新加载
    supervisorctl -c supervisord.conf reload
    
    # 使用supervisorctl启动nginx服务
    supervisorctl start nginx
    
    #查看状态
    supervisorctl status
    
posted on 2020-01-20 13:58  猛风中碰杯  阅读(2036)  评论(0编辑  收藏  举报