使用 supervisor 管理进程

http://www.cnblogs.com/smail-bao/p/5673434.html

http://ju.outofmemory.cn/entry/201847

http://cpper.info/2016/04/14/supervisor-usage.html

http://xitongjiagoushi.blog.51cto.com/9975742/1710321

http://liyangliang.me/posts/2015/06/using-supervisor/

这个可是一个好东西,以后再也不用 nohup  XXXX &  了。有了它,妈妈再也不用担心我的学习了

我这里用[root@git logs]# easy_install supervisor的方式安装,之前我也试过用pip的方式安装,但是我装好之后,创建配置文件的时候报错了,

一直也没有找到原因,希望哪位朋友看到的时候帮忙和我说一下,谢谢

或者是源码安装

wget https://pypi.python.org/packages/source/s/supervisor/supervisor-3.1.3.tar.gz --no-check-certificat

tar zxf supervisor-3.1.3.tar.gz

cd supervisor-3.1.3

python setup.py install

/usr/local/bin/echo_supervisord_conf >> /etc/supervisord.conf

装好之后

生成配置文件

echo_supervisord_conf > /etc/supervisord.conf

我们现在多虑一下看看里面有哪些有效内容

[root@zabbix ansible]# cat supervisord.conf | grep -v "^;" | grep -v "^$"
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
[supervisord]
user=root
logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
#serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
###为了不将所有新增配置信息全写在一个配置文件里,这里新建一个文件夹,每个程序设置一个配置文件,相互隔离
mkdir /etc/supervisord.d/ ### 修改配置文件
vim /etc/supervisord.conf ### 加入以下配置信息
[include]
files = /etc/supervisord.d/*.conf ### 在supervisord.conf中设置通过web可以查看管理的进程,加入以下代码(默认即有,取消注释即可)
[inet_http_server]
port=9001
username=user
password=123
然后我们这里就可以使用http://IP:9001来登陆管理界面 这里我们可以选择使用脚本来启动,停止supervisor 启动脚本为
  1. wget https://github.com/Supervisor/initscripts/raw/master/redhat-init-mingalevme
[root@zabbix ~]# cat /etc/init.d/supervisor 
#!/bin/bash
#
# supervisord This scripts turns supervisord on
#
# Author: Mike McGrath <mmcgrath@redhat.com> (based off yumupdatesd)
# Jason Koppe <jkoppe@indeed.com> adjusted to read sysconfig,
# use supervisord tools to start/stop, conditionally wait
# for child processes to shutdown, and startup later
# Mikhail Mingalev <mingalevme@gmail.com> Merged
# redhat-init-jkoppe and redhat-sysconfig-jkoppe, and
# made the script "simple customizable".
# Brendan Maguire <maguire.brendan@gmail.com> Added OPTIONS to
# SUPERVISORCTL status call
#
# chkconfig: 345 83 04
#
# description: supervisor is a process control utility. It has a web based
# xmlrpc interface as well as a few other nifty features.
# Script was originally written by Jason Koppe <jkoppe@indeed.com>.
# # source function library
. /etc/rc.d/init.d/functions set -a PREFIX=/usr/local SUPERVISORD=$PREFIX/bin/supervisord
SUPERVISORCTL=$PREFIX/bin/supervisorctl PIDFILE=/var/run/supervisord.pid
LOCKFILE=/var/lock/subsys/supervisord OPTIONS="-c /etc/supervisord.conf" # unset this variable if you don't care to wait for child processes to shutdown before removing the $LOCKFILE-lock
WAIT_FOR_SUBPROCESSES=yes # remove this if you manage number of open files in some other fashion
ulimit -n 96000 RETVAL=0 running_pid()
{
# Check if a given process pid's cmdline matches a given name
pid=$1
name=$2
[ -z "$pid" ] && return 1
[ ! -d /proc/$pid ] && return 1
(cat /proc/$pid/cmdline | tr "\000" "\n"|grep -q $name) || return 1
return 0
} running()
{
# Check if the process is running looking at /proc
# (works for all users) # No pidfile, probably no daemon present
[ ! -f "$PIDFILE" ] && return 1
# Obtain the pid and check it against the binary name
pid=`cat $PIDFILE`
running_pid $pid $SUPERVISORD || return 1
return 0
} start() {
echo "Starting supervisord: " if [ -e $PIDFILE ]; then
echo "ALREADY STARTED"
return 1
fi # start supervisord with options from sysconfig (stuff like -c)
$SUPERVISORD $OPTIONS # show initial startup status
$SUPERVISORCTL $OPTIONS status # only create the subsyslock if we created the PIDFILE
[ -e $PIDFILE ] && touch $LOCKFILE
} stop() {
echo -n "Stopping supervisord: "
$SUPERVISORCTL $OPTIONS shutdown
if [ -n "$WAIT_FOR_SUBPROCESSES" ]; then
echo "Waiting roughly 60 seconds for $PIDFILE to be removed after child processes exit"
for sleep in 2 2 2 2 4 4 4 4 8 8 8 8 last; do
if [ ! -e $PIDFILE ] ; then
echo "Supervisord exited as expected in under $total_sleep seconds"
break
else
if [[ $sleep -eq "last" ]] ; then
echo "Supervisord still working on shutting down. We've waited roughly 60 seconds, we'll let it do its thing from here"
return 1
else
sleep $sleep
total_sleep=$(( $total_sleep + $sleep ))
fi fi
done
fi # always remove the subsys. We might have waited a while, but just remove it at this point.
rm -f $LOCKFILE
} restart() {
stop
start
} case "$1" in
start)
start
RETVAL=$?
;;
stop)
stop
RETVAL=$?
;;
restart|force-reload)
restart
RETVAL=$?
;;
reload)
$SUPERVISORCTL $OPTIONS reload
RETVAL=$?
;;
condrestart)
[ -f $LOCKFILE ] && restart
RETVAL=$?
;;
status)
$SUPERVISORCTL $OPTIONS status
if running ; then
RETVAL=0
else
RETVAL=1
fi
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
exit 1
esac exit $RETVAL

Linux 进程管理器 supervixor的更多相关文章

  1. Linux进程管理 (2)CFS调度器

    关键词: 目录: Linux进程管理 (1)进程的诞生 Linux进程管理 (2)CFS调度器 Linux进程管理 (3)SMP负载均衡 Linux进程管理 (4)HMP调度器 Linux进程管理 ( ...

  2. 12个Linux进程管理命令介绍(转)

    12个Linux进程管理命令介绍 [日期:2015-06-02] 来源:Linux中国  作者:Linux [字体:大 中 小]   执行中的程序在称作进程.当程序以可执行文件存放在存储中,并且运行的 ...

  3. Linux进程管理知识整理

    Linux进程管理知识整理 1.进程有哪些状态?什么是进程的可中断等待状态?进程退出后为什么要等待调度器删除其task_struct结构?进程的退出状态有哪些? TASK_RUNNING(可运行状态) ...

  4. Linux性能及调优指南(翻译)之Linux进程管理

    本文为IBM RedBook的Linux Performanceand Tuning Guidelines的1.1节的翻译原文地址:http://www.redbooks.ibm.com/redpap ...

  5. Linux进程管理专题

    Linux进程管理 (1)进程的诞生介绍了如何表示进程?进程的生命周期.进程的创建等等? Linux支持多种调度器(deadline/realtime/cfs/idle),其中CFS调度器最常见.Li ...

  6. [转帖]十二 个经典 Linux 进程管理命令介绍

    https://www.cnblogs.com/swordxia/p/4550825.html 接了 http referer 头 没法显示图片 可以去原始blog 里面去查看.   随笔- 109  ...

  7. Linux进程管理 (1)进程的诞生

    专题:Linux进程管理专题 目录: Linux进程管理 (1)进程的诞生 Linux进程管理 (2)CFS调度器 Linux进程管理 (3)SMP负载均衡 Linux进程管理 (4)HMP调度器 L ...

  8. Linux进程管理 (7)实时调度

    关键词:RT.preempt_count.RT patch. 除了CFS调度器之外,还包括重要的实时调度器,有两种RR和FIFO调度策略.本章只是一个简单的介绍. 更详细的介绍参考<Linux进 ...

  9. PHP FastCGI进程管理器PHP-FPM的架构

    一个master进程,支持多个pool,每个pool由master进程监听不同的端口,pool中有多个worker进程.每个worker进程都内置PHP解释器,并且进程常驻后台,支持prefork动态 ...

随机推荐

  1. 无向图的最短路径算法JAVA实现

    一,问题描述 给出一个无向图,指定无向图中某个顶点作为源点.求出图中所有顶点到源点的最短路径. 无向图的最短路径其实是源点到该顶点的最少边的数目. 本文假设图的信息保存在文件中,通过读取文件来构造图. ...

  2. Medial Queries的另一用法:实现IE hack的方法

    所谓Medial Queries就是媒体查询. 随着Responsive设计的流行,Medial Queries可算是越来越让人观注了.他可以让Web前端工程实现不同设备下的样式选择,让站点在不同的设 ...

  3. 《至少有那天》——IU

    //<你的意义>中文版 那天冷的让人好想哭 可是我那一天看到了爱情 湖边的薄冰和老树 就在零下七度那一天 你和我牵手 慢慢聊着以前那些童话 可能它们都有些意义吧 是吗 一个吻 一滴眼泪 一 ...

  4. Doxygen Tool For Unity

    一.准备阶段 在之前的一系列文章中,我尝试了不同方法为Unity的C#生成脚本手册(帮助文档) 使用Doxygen生成C#帮助文档 为Unity项目生成文档(一)为Unity项目生成文档(二) 建议的 ...

  5. python案例-用户登录

    要求: •输入用户名密码 •认证成功后显示欢迎信息 •输错三次后锁定 1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 4 "" ...

  6. NOI 1.7编程基础之字符串(35题)

    01:统计数字字符个数 查看 提交 统计 提问 总时间限制:  1000ms 内存限制:  65536kB 描述 输入一行字符,统计出其中数字字符的个数. 输入 一行字符串,总长度不超过255. 输出 ...

  7. 24Spring_事务管理机制

    第一部分:Spring事务管理高层抽象接口 我们介绍三个接口:1.PlatformTransactionManager 2.TransactionDefinition  3.TransactionSt ...

  8. usb驱动开发10之usb_device_match

    在第五节我们说过会专门分析函数usb_device_match,以体现模型的重要性.同时,我们还是要守信用的. 再贴一遍代码,看代码就要不厌其烦. static int usb_device_matc ...

  9. MTK android 工程中如何修改照片详细信息中机型名

    每一个项目的机型名都不相同,因此拍出来的照片需要更改详细信息中的机型名. 那么,具体在哪里修改照片详细信息机型名呢 路径信息:/ALPS.JB3.TDD.MP.V2_TD_xxx/mediatek/c ...

  10. Unity架构有点乱

    1,没有合理的将公共的东西归入到基类中,而是分散到子类中,有许多重复. 比如 enbled的变量本应该是所有component所共有的一个属性,应该写在component.然而却发现并非这样,enbl ...