Supervisor 进程管理工具
简介:
Supervisor 进程管理工具
一、安装
shell > yum -y install python-pip shell > pip install supervisor # 这样就安装好了,注意:这货不支持 Python 、用 yum 安装也有问题
二、配置
shell > echo_supervisord_conf > /etc/supervisord.conf # 生成配置文件到指定位置,报错的时候卸载原来的包装这个 meld3==0.6.7 [ pkg_resources.DistributionNotFound: meld3>=0.6.5 ] shell > grep -vP '^;|^$' /etc/supervisord.conf [unix_http_server]
file=/var/tmp/supervisor.sock ; .sock 存放位置 [supervisord]
logfile=/var/log/supervisord.log ; .log 存放位置
logfile_maxbytes=50MB ; 每个日志文件最大 50MB
logfile_backups= ; 保留10个备份
loglevel=info ; 日志级别,info,debug,warn,trace
pidfile=/var/run/supervisord.pid ; .pid 存放位置
nodaemon=false ; 守护进程方式启动
minfds= ; 可以打开的文件描述符
minprocs= ; 可以启动的进程数 [rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl]
serverurl=unix:///var/tmp/supervisor.sock ; .sock 存放位置 # 稍微修改了一些默认项
三、启动
shell > supervisord -c /etc/supervisord.conf # 指定配置文件路径 shell > ps aux | grep sup
root 0.0 0.0 ? S : : [sync_supers]
root 0.0 0.1 ? Ss : : /usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf
四、启动一个自定义脚本
shell > vim hello.sh
#!/bin/bash
for i in {..};do echo hello; sleep ;done
shell > chmod a+x hello.sh
shell > vim /etc/supervisord.conf [program:hello]
directory=/root ; 运行程序时切换到指定目录
command=/bin/bash hello.sh ; 执行程序 ( 程序不能时后台运行的方式 )
redirect_stderr=true ; 标准错误输出重定向到标准输出
stdout_logfile=hello.log ; 指定日志文件路径,可以绝对路径 ( 相对路径 相对 directory= 指定的目录 )
stdout_logfile_maxbytes=50MB ; 文件切割大小
stdout_logfile_backups= ; 保留的备份数 # 加入程序启动配置
shell > supervisorctl supervisor> help default commands (type help <topic>):
=====================================
add exit open reload restart start tail
avail fg pid remove shutdown status update
clear maintail quit reread signal stop version # 客户端工具提供一些指令 ( supervisorctl help 这样运行也是可以的 ) supervisor> update
hello: added process group # 自动重启配置文件发生改变的进程 supervisor> start hello
hello: started supervisor> status
hello RUNNING pid , uptime :: # 反正就是这几个指令,启动后脚本的输出会被记录到 stdout_logfile= 指定的日志文件中 # 现在的情况是,程序执行一次就退出了 supervisor> status
hello EXITED Dec : PM supervisor> exit
shell > vim /etc/supervisord.conf [program:hello]
directory=/root
command=/bin/bash hello.sh
autostart=true ; 程序随 supervisord 启动而启动
startsecs= ; 程序启动 后没有退出,认为程序启动成功
startretries= ; 启动失败重试次数
autorestart=true ; 程序退出后自动启动,false 不启动、unexpected 只有退出状态码为 exitcodes= 指定的值是才自动启动
redirect_stderr=true
stdout_logfile=hello.log
stdout_logfile_maxbytes=50MB
stdout_logfile_backups= # 添加一些配置,重新来过 supervisor> update
hello: stopped
hello: updated process group # 注意:这次会时间长一点,因为设置了 startsecs=,也就是说 秒后才能 status 看到进程状态 # 这次程序就会自动重启了
shell > vim /etc/supervisord.conf [program:hello]
directory=/root
command=/bin/bash hello.sh
process_name=%(program_name)s_%(process_num)02d ; 启动多个进程时设置不同的进程名
numprocs= ; 启动几个进程
autostart=true
startsecs=
startretries=
autorestart=true
redirect_stderr=true
stdout_logfile=hello.log
stdout_logfile_maxbytes=50MB
stdout_logfile_backups= # 又加了启动多个进程的配置 supervisor> update
hello: stopped
hello: updated process group supervisor> status
hello:hello_00 RUNNING pid , uptime ::
hello:hello_01 RUNNING pid , uptime :: # 这次长这样了.. supervisor> stop all
hello:hello_00: stopped
hello:hello_01: stopped supervisor> status
hello:hello_00 STOPPED Dec : PM
hello:hello_01 STOPPED Dec : PM # 好了收工!
Supervisor 进程管理工具的更多相关文章
- linux(centos)下安装supervisor进程管理工具
在接触supervisor进程管理工具之前,使用springboot打包部署到linux服务器的流程是这样子的,如下图所示: 上图展示的就是最一般的流程,如果项目是小项目或者demo可以这样子去部署, ...
- supervisor进程管理工具的使用
supervisor是一款进程管理工具,当想让应用随着开机启动,或者在应用崩溃之后自启动的时候,supervisor就派上了用场. 广泛应用于服务器中,用于引导控制程序的启动 安装好superviso ...
- supervisor进程管理工具
Supervisor 一个python写的进程管理工具,用来启动.关闭.重启进程,可以同时控制多个进程. 安装: pip install supervisor 配置: 通过配置文件来满足自己的需求 配 ...
- python之supervisor进程管理工具
supervisor是python写的一个管理进程运行的工具,可以很方便的监听.启动.停止.重启一个或多个进程:有了supervisor后,就不用字节写启动和监听的shell脚本了,非常方便. sup ...
- CentOS 6.3安装配置supervisor进程管理工具
1. Supervisor是一个C/S系统,它可以在类unix操作系统让用户来监视和控制后台服务进程的数量,一个很重要的功能就是监控服务器的主要后台进程,并在出现问题是自动重启. 2. 根据服务器上的 ...
- 进程管理工具之supervisor[详解]
原文链接:https://blog.csdn.net/weixin_42390791/article/details/88866237 一.问题背景1.背景 如何才能让一个进程摆脱终端,获得相对 ...
- Linux进程管理工具——supervisor
介绍 Supervisord是用Python实现的一款非常实用的进程管理工具 安装 这里用源码 supervisor-.tar.gz .tar.gz cd supervisor- sudo pytho ...
- supervisor python开发的进程管理工具
Supervisor (http://supervisord.org) 是一个用 Python 写的进程管理工具,可以很方便的用来启动.重启.关闭进程(不仅仅是 Python 进程).除了对单个进程的 ...
- Python 进程管理工具 Supervisor 使用教程
Supervisor 是基于 Python 的进程管理工具,只能运行在 Unix-Like 的系统上,也就是无法运行在 Windows 上.Supervisor 官方版目前只能运行在 Python 2 ...
随机推荐
- kafka 安装与配置
下载 地址:https://kafka.apache.org/downloads 这里下载的是kafka_2.11-0.11.0.1.tgz 解压 tar -xzf kafka_2.11-0.11.0 ...
- linux svn服务器(一)
先安装 参考文章http://www.cnblogs.com/zhaoyang-1989/articles/3455481.html
- 关于java泛型的使用方式。。。。
转自:http://onewebsql.com/blog/generics-extends-super 以下基本够用了 Today we continue our mini-series on Jav ...
- MessageFormat用法(转载)
MessageFormat用来格式化一个消息,通常是一个字符串,比如: String str = "I'm not a {0}, age is {1,number,short}", ...
- java正则表达式学习
1.简单认识正则: public class Test { public static void main(String[] args) { //简单认识正则 p("abc".ma ...
- ASP.NET Web Pages:Chart 帮助器
ylbtech-.Net-ASP.NET Web Pages:Chart 帮助器 1.返回顶部 1. ASP.NET Web Pages - Chart 帮助器 Chart 帮助器 - 众多有用的 A ...
- windows基础应用(word)
自动编号-最后选择一下编号格式 TAB 进入子节 shift+TAB 回退到父节 取消邮箱/网址链接 ctrl+z word中输入不认识生僻字:输入偏旁部首王,选中插入中寻找 输入英文时,更改大小写/ ...
- 定义function的层级
不知道标题拟的对不对,今天犯了个错误,图一是正确的写法. 图一 为了代码可以重复利用,我把其中两个方法独立出来,如图二. 图二 后来发现运行错误,说Gxrc未定义,百思不得其解,后来琢磨了好久,才发现 ...
- 在ie6下的png图片的兼容问题
png图片在ie6下是这样的: 正确样式: 这样解决: html代码: <body> <div class="gys"></div> </ ...
- Jquery阻断事件冒泡(转载)
JQuery阻止事件冒泡 冒泡事件就是点击子节点,会向上触发父节点,祖先节点的点击事件. 我们在平时的开发过程中,肯定会遇到在一个div(这个div可以是元素)包裹一个div的情况,但是呢,在这两个d ...