linux 进程监控软件 supervisor

简介: 2017年8月21日 17:51:33 星期一 supervisor python写的, 用来监控进程是否启动, 之前监控进程是否启动, 没有就拉起的shell代码是写在crontab里的, 这个软件提供了配置管理功能 参考文章: 配置1:  http://www.

2017年8月21日 17:51:33 星期一

supervisor python写的, 用来监控进程是否启动,

之前监控进程是否启动, 没有就拉起的shell代码是写在crontab里的, 这个软件提供了配置管理功能

参考文章:

配置1:  http://www.cnblogs.com/lianer/p/5560922.html

配置2: http://www.cnblogs.com/shijingjing07/p/6024066.html

//=======安装======//

下载python安装器: https://pypi.python.org/pypi/setuptools

python 2.6/2.7 安装"安装器": http://blog.csdn.net/ab198604/article/details/8681851  (注, centos 6.x yum默认是python 2.6, 安装命令 python setup.py install, 升级pytho 2.7后yum会不可用)

官方安装指导: http://www.supervisord.org/installing.html

官方配置文件解释: http://www.supervisord.org/configuration.html

//=======配置翻译=======//

[program:x]

冒号紧跟在program后边

x是应用的名字, 也被supervisor的相关控制命令来使用;x值不能为空, 也不能含有冒号和括号;x的值还用于%(program_name)s表达式

如果x=foo且指令numprocs=3, process_name=%(program_name)s_%(process_num)02d 那么就会启动3个进程, 名字分别为foo_01,foo_02,foo_03;

如果不指定这几个值,那么就启动一个进程, 名字为x

命令 是否必须 默认值 解释
command y   要执行、监控的命令
process_name n %(program_name)s 启动后进程名, 常结合numprocs指令值使用
numprocs n 1 启动进程数
numprocs_start n 0 整数偏移量,从numprocs中的第几个开始启动
priority n 999 当执行start all/stop all时启动/停止的顺序, 值越小越先启动越后停止
autostart n true supervisord启动的时候自动启动
startsecs n 1 启动后延迟多少秒后执行命令
startretries n 3 失败后重试次数
autorestart n unexpected 重新拉起 false、unexpected(发现程序退出,根据exit_code选择性是否重启)、true(发现程序退出,则无条件重启)
exitcodes n 0,2 配合autorestart=unexpected时使用

 

举例:

1 [program:activityCandleSendCouponQueue]
2 directory=/mnt/hostcode/openapi/basic_service
3 command=php7 artisan queue:work redis --queue=activityCandleSendCoupon
4 autorestart=true
5 stdout_logfile=/usr/local/supervisor/activityCandleSendCouponQueue.log
1 ps -ef | grep queue
2 www       3578  3575  0 Aug23 pts/1    00:00:15 php7 artisan queue:work redis --queue=activityCandleSendCoupon

 

目录
相关文章
|
2天前
|
消息中间件 算法 Linux
【Linux】详解如何利用共享内存实现进程间通信
【Linux】详解如何利用共享内存实现进程间通信
|
2天前
|
Linux
【Linux】命名管道的创建方法&&基于命名管道的两个进程通信的实现
【Linux】命名管道的创建方法&&基于命名管道的两个进程通信的实现
|
2天前
|
Linux
【Linux】匿名管道实现简单进程池
【Linux】匿名管道实现简单进程池
|
2天前
|
Linux
【Linux】进程通信之匿名管道通信
【Linux】进程通信之匿名管道通信
|
2天前
|
存储 Linux Shell
Linux:进程等待 & 进程替换
Linux:进程等待 & 进程替换
30 9
|
2天前
|
存储 Linux C语言
Linux:进程创建 & 进程终止
Linux:进程创建 & 进程终止
26 6
|
2天前
|
Linux 数据库
linux守护进程介绍 | Linux的热拔插UDEV机制
linux守护进程介绍 | Linux的热拔插UDEV机制
linux守护进程介绍 | Linux的热拔插UDEV机制
|
2天前
|
Unix Linux 调度
linux线程与进程的区别及线程的优势
linux线程与进程的区别及线程的优势
|
2天前
|
Linux 调度 C语言