Centos7 使用 supervisor 管理进程
一、安装
//直接使用pip安装(pip的安装 http://www.cnblogs.com/yxhblogs/p/8971251.html)
pip install supervisor
二、配置
//运行echo_supervisord_conf 命令重定向到一个配置文件
echo_supervisord_conf > /etc/supervisord.conf
三、修改配置文件
//创建一个目录
mkdir /etc/supervisor.d
//把/etc/supervisord.conf 里 include 部分的的配置修改一下,改为如下:
[include]
files = /etc/supervisor.d/*.conf
四、program 配置
[root@localhost supervisord.d]# cat test.conf
;[program:theprogramname]
;command=/bin/cat ; the program (relative uses PATH, can take args) //启动命令,与手动在命令行启动的命令是一样的
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;numprocs=1 ; number of processes copies to start (def 1)
;directory=/var/tmp ; directory to cwd to before exec (def no cwd) //程序的启动目录
;umask=022 ; umask for process (default None)
;priority=999 ; the relative start priority (default 999)
;autostart=true ; start at supervisord start (default: true) //在 supervisord 启动的时候也自动启动
;startsecs=1 ; # of secs prog must stay up to be running (def. 1) //启动 1 秒后没有异常退出,就当作已经正常启动了
;startretries=3 ; max # of serial start failures when starting (default 3) //启动失败自动重试次数,默认是 3
;autorestart=unexpected ; when to restart if exited after running (def: unexpected)
;exitcodes=0,2 ; 'expected' exit codes used with autorestart (default 0,2)
;stopsignal=QUIT ; signal used to kill process (default TERM)
;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
;stopasgroup=false ; send stop signal to the UNIX process group (default false)
;killasgroup=false ; SIGKILL the UNIX process group (def false)
;user=chrism ; setuid to this UNIX account to run the program //用哪个用户启动
;redirect_stderr=true ; redirect proc stderr to stdout (default false) //把 stderr 重定向到 stdout,默认 false
;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB) //stdout 日志文件大小,默认 50MB
;stdout_logfile_backups=10 ; # of stdout logfile backups (0 means none, default 10) //stdout 日志文件备份数 , 默认10
;stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
;stdout_events_enabled=false ; emit events on stdout writes (default false)
;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10 ; # of stderr logfile backups (0 means none, default 10)
;stderr_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
;stderr_events_enabled=false ; emit events on stderr writes (default false)
;environment=A="1",B="2" ; process environment additions (def no adds)
;serverurl=AUTO ; override serverurl computation (childutils)
更详细配置请参考:https://blog.csdn.net/chenyulancn/article/details/52789565
五、启动
//启动supervisor
supervisord -c /etc/supervisord.conf
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
2016-04-29 接口开发之PHP创建XML文件