【多进程同时管理】supervisor 进程管理

推荐文章参考:https://www.jianshu.com/p/805977544d7f

参考:http://ju.outofmemory.cn/entry/104865

特别注意:supervisor 只能监控前端运行的程序【daemon必须设置为false】

常见错误类型一:https://blog.csdn.net/weixin_43343144/article/details/97686956

错误类型二:https://blog.csdn.net/weixin_43343144/article/details/97688485

官方配置文档:http://supervisord.org/configuration.html

一个成功的配置案例【多文件配置】:

; /etc/supervisord.conf主配置文件

[unix_http_server]
file=/tmp/supervisor.sock   ; UNIX socket 文件,supervisorctl 会使用
;chmod=0700                 ; socket 文件的 mode,默认是 0700
;chown=nobody:nogroup       ; socket 文件的 owner,格式: uid:gid

; [inet_http_server]         ; HTTP 服务器,提供 web 管理界面
; port=0.0.0.0:8080        ; Web 管理后台运行的 IP 和端口,如果开放到公网,需要注意安全性
; username=root              ; 登录管理后台的用户名
; password=1123               ; 登录管理后台的密码

[supervisord]
logfile=/tmp/supervisord.log ; 日志文件,默认是 $CWD/supervisord.log
logfile_maxbytes=50MB        ; 日志文件大小,超出会 rotate,默认 50MB
logfile_backups=10           ; 日志文件保留备份数量默认 10
loglevel=info                ; 日志级别,默认 info,其它: debug,warn,trace
pidfile=/tmp/supervisord.pid ; pid 文件
nodaemon=false               ; 是否在前台启动,默认是 false,即以 daemon 的方式启动
minfds=1024                  ; 可以打开的文件描述符的最小值,默认 1024
minprocs=200                 ; 可以打开的进程数的最小值,默认 200

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; 通过 UNIX socket 连接 supervisord,路径与 unix_http_server 部分的 file 一致
; serverurl=http://127.0.0.1:8080 ; 通过 HTTP 的方式连接 supervisord

; 包含其他的配置文件
[include]
files = /etc/supervisor/*.conf    ; 可以是 *.conf 或 *.ini

 

; gunicorn进程文件:supervisor/supervisord_gunicorn.conf

[program:gunicorn]
directory=/root/uniapp-Flask ; 非常重要,选择在那个目录下执行命令
command=/root/.local/share/virtualenvs/uniapp-Flask-dCCHvjvS/bin/gunicorn -c other_config/gunicorn.py main:app ; command这里的gunicorn一定是你程序运行的python环境【如果虚拟环境就必须选择虚拟环境下面的路径】
autostart = true     ; 在 supervisord 启动的时候也自动启动
autorestart = true   ; 程序异常退出后自动重启
startsecs = 3        ; 启动 3 秒后没有异常退出,就当作已经正常启动了
startretries = 3     ; 启动失败自动重试次数,默认是 3
redirect_stderr = true  ; 把 stderr 重定向到 stdout,默认 false
user=root                
loglevel=info
; 这一配置项的作用是:如果supervisord管理的进程px又产生了若干子进程,使用supervisorctl停止px进程,停止信号会传播给px产生的所有子进程,确保子进程也一起停止。这一配置项对希望停止所有进程的需求是非常有用的。
stopasgroup=true
[supervisord] ; 必须配置
[supervisorctl] ; 必须配置
; nginx进程文件:supervisor/supervisord_nginx.conf

[program:nginx]
command=nginx
autostart = true     ; 在 supervisord 启动的时候也自动启动
autorestart = true   ; 程序异常退出后自动重启
startsecs = 3        ; 启动 3 秒后没有异常退出,就当作已经正常启动了
startretries = 3     ; 启动失败自动重试次数,默认是 3
redirect_stderr = true  ; 把 stderr 重定向到 stdout,默认 false
user=root                
loglevel=info
; 这一配置项的作用是:如果supervisord管理的进程px又产生了若干子进程,使用supervisorctl停止px进程,停止信号会传播给px产生的所有子进程,确保子进程也一起停止。这一配置项对希望停止所有进程的需求是非常有用的。
stopasgroup=true
[supervisord] ; 必须配置
[supervisorctl] ; 必须配置

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值