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 ...
随机推荐
- POJ2955Brackets——dp
题目:http://poj.org/problem?id=2955 1.考虑区间. 2.当前区间可为自己子区间的和(题意果然是和而非最大值). 3.考虑当前区间的边界. #include<ios ...
- asp.net如何使用cookie(创建、保存、读取)
Cookie的用法也和ASP中差不多.比如我们建立一个名为aspcn,值为大众的cookie HttpCookie cookie = new HttpCookie("aspcn") ...
- Centos 配置ifconfig命令
刚装完CentOS 后ifconfig命令可能是不可用的,那么需要以下配置 ip addr vi /etc/sysconfig/network-scripts/ifcfg-xx (ONBOOT=yes ...
- android自定义tabhost,tabcontent用intent获得
地址:http://my.oschina.net/aowu/blog/36282 自己改的自定义tabhost组建,效果图如左.有更好的朋友可以相互交流一下,嘿嘿. 1.先上AndroidManife ...
- springMVC集成CXF后调用已知的wsdl接口
本文转载自:https://www.cnblogs.com/xiaochangwei/p/5400303.html 本篇文章将讲解SpringMVC+CXF环境下,怎么调用其他系统通过webServi ...
- bzoj 2571: Getting Rid of the Holidays
Description B国的国王Johnny在他在位的短短几年里制定了不少的节日(事实上没超过30个),这些节日是为了尊敬各种各样他所想到的东西而设立的.每过一段固定的时间,一个节日将会被举行(即节 ...
- 1035 Password (20 分)
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...
- linux下给php安装curl、gd(ubuntu)
安装方法很简单,只需要一条命令. # sudo apt-get install curl libcurl3 libcurl3-dev php5-curl 恭喜,PHP5 cURL安装完毕.记得重启Ap ...
- sklearn 线性模型使用入门
LinearRegression fits a linear model with coefficients to minimize the residual sum of squares betw ...
- Unreal Engine 4(虚幻UE4)GameplayAbilities 插件入门教程(二)
我们接着学习.如果没有学习第一篇,请前往学习. 由于GameplayAbilities插件基本上没有资料(除了前面提供的那篇Dave的博文以外,再无资料,有迹象表明Dave是这个插件的开发者). 这个 ...