supervisor使用
supervisor是一个C/S系统,它可以在类unix操作系统让用户来监视和控制后台服务进程的数量,一个很重要的功能就是监控服务器的主要后台进程,并在出现问题是自动重启。
根据服务器上的python版本下载对应的setuptools
[root@test1 ~]# python -V Python wget http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg#md5=bfa92100bd772d5a213eedd356d64086 直接安装 sh setuptools-.6c11-py2..egg
下载并且安装supervisor
wget http://pypi.python.org/packages/source/s/supervisor/supervisor-3.0b1.tar.gz tar -zxvf supervisor-.0b1.tar.gz cd supervisor-.0b1 python setup.py install 安装setuptools后也可以 easy_install supervisor
设定supervisor配置文件
创建默认的配置文件 echo_supervisord_conf >/etc/supervisord.conf vi /etc/supervisord.conf 取消以下的注释,并修改IP为0. [inet_http_server] ; inet (TCP) server disabled by default port= ; (ip_address:port specifier, *:port for all iface) username=user ; (default is no username (open server)) password= ; (default is no password (open server)) 增加自定义的后台进程(注意进程名之间用一个:分隔) [program:hello] command=python /root/hello.py priority= numprocs= autostart=true autorestart=true startretries= stopsignal=KILL stopwaitsecs= redirect_stderr=true stdout_logfile=/root/hello.log
设定supervisor启动文件
vi /etc/init.d/supervisord
#! /bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
PROGNAME=supervisord
DAEMON=/usr/bin/$PROGNAME
CONFIG=/etc/$PROGNAME.conf
PIDFILE=/tmp/$PROGNAME.pid
DESC="supervisord daemon"
SCRIPTNAME=/etc/init.d/$PROGNAME
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit
start()
{
echo -n "Starting $DESC: $PROGNAME"
$DAEMON -c $CONFIG
echo "..."
}
stop()
{
echo -n "Stopping $DESC: $PROGNAME"
supervisor_pid=$(cat $PIDFILE)
kill - $supervisor_pid
echo "..."
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo
exit
;;
esac
exit
写一个简单的python脚本
安装web.py
easy_install web.py
vi /root/hello.py
import web
urls = (
'/(.*)', 'hello'
)
app = web.application(urls, globals())
class hello:
def GET(self, name):
if not name:
name = 'World'
return 'Hello, ' + name + '!'
if __name__ == "__main__":
app.run()
启动supervisor服务,并观察hello服务状态
/etc/init.d/supervisord start 查看日志 tail -f /tmp/supervisord.log -- ::, WARN received SIGTERM indicating exit request -- ::, INFO waiting for :hello to die -- ::, INFO stopped: :hello (terminated by SIGKILL) -- ::, CRIT Supervisor running as root (no user in config file) -- ::, INFO RPC interface 'supervisor' initialized -- ::, CRIT Server 'unix_http_server' running without any HTTP authentication checking -- ::, INFO daemonizing the supervisord process -- ::, INFO supervisord started with pid -- ::, INFO spawned: -- ::, INFO success: :hello entered RUNNING state, process has stayed up seconds (startsecs) 可以使用supervisorctl管理进程 upervisorctl status 查询状态 supervisorctl start hello 开启服务 supervisorctl stop hello 关闭服务
之前配置文件开启了web访问,这样可以直接通过浏览器观察和控制进程,非常方便


参考:http://supervisord.org/
supervisor使用的更多相关文章
- asp.net core 负载均衡集群搭建(centos7+nginx+supervisor+kestrel)
概述 本文目的是搭建三台asp.net core 集群, 并配上 nginx做负载均衡 首先准备要运行的源码 http://pan.baidu.com/s/1c20x0bA 准备三台服务器(或则虚 ...
- 进程监控工具supervisor 启动Mongodb
进程监控工具supervisor 启动Mongodb 一什么是supervisor Superviosr是一个UNIX-like系统上的进程监控工具. Supervisor是一个Python开发的cl ...
- Linux Supervisor 守护进程基本配置
supervisor:C/S架构的进程控制系统,可使用户在类UNIX系统中监控.管理进程.常用于管理与某个用户或项目相关的进程. 组成部分supervisord:服务守护进程supervisorctl ...
- supervisor的安装与简单介绍
1,介绍 Supervisor是一个进程管理工具,官方的说法 用途就是有一个进程需要每时每刻不断的跑,但是这个进程又有可能由于各种原因有可能中断.当进程中断的时候我希望能自动重新启动它,此时,我就需要 ...
- supervisor监管进程max file descriptor配置不生效的问题
配置了 sudo vim /etc/security/limits.conf * soft nofile * hard nofile 单独起进程没问题, 放到supervisor下监管启动,则报错 ...
- centos 6.7 搭建tornado + nginx + supervisor的方法(已经实践)
首先,本来不想写这篇博客了,但是我测试了很多网上的例子包括简书的,全不行,我总结原因是自己太笨,搞了俩个晚上,后来决定,自己还是写一篇记录下来,保证自己以后使用 环境: centos6.7 64 py ...
- python supervisor使用
Supervisor 是基于 Python 的进程管理工具,只能运行在 Unix-Like 的系统上,也就是无法运行在 Windows 上.Supervisor 官方版目前只能运行在 Python 2 ...
- 进程管理supervisor的简单说明
背景: 项目中遇到有些脚本需要通过后台进程运行,保证不被异常中断,之前都是通过nohup.&.screen来实现,带着能否做一个start/stop/restart/reload的服务启动的想 ...
- Linux守护进程之Supervisor
1. 什么是守护进程 在linux或者unix操作系统中,守护进程(Daemon)是一种运行在后台的特殊进程,它独立于控制终端并且周期性的执行某种任务或等待处理某些发生的事件.由于在linux中,每个 ...
- supervisor 安装、配置、常用命令
前言 在 web 应用部署到线上后,需要保证应用一直处于运行状态,在遇到程序异常.报错等情况,导致 web 应用终止时,需要保证程序可以立刻重启,继续提供服务. 所以,就需要一个工具,时刻监控 web ...
随机推荐
- PyQt4关闭最大化最小化取消双击最大化
self.setWindowFlags(Qt.Window | Qt.WindowTitleHint | Qt.WindowCloseButtonHint | Qt.CustomizeWindowHi ...
- 获取shell脚本自身所在目录的Shell脚本分享
前几天写的七牛的参赛demo,用bash写了一个便捷安装的脚本,涉及到了路径相关的判断,从stackoverflow,加上自己的实践整理一下. 简单版 下面是一个最简单的实现,可以解决大多数问题,缺陷 ...
- SQL Server日期和时间的格式
在SQL Server数据库中,SQL Server日期时间格式转换字符串可以改变SQL Server日期和时间的格式,是每个SQL数据库用户都应该掌握的.本文我们主要就介绍一下SQL Server日 ...
- Ebase Xi The world's best RAD platform.
Ebase Xi : http://www.ebasetech.com/ The world's best RAD platform. Xi combines browser and mobile a ...
- 【leetcode】Convert Sorted Array to Binary Search Tree
Convert Sorted Array to Binary Search Tree Given an array where elements are sorted in ascending ord ...
- POJ 3414
http://poj.org/problem?id=3414 这是一个广搜的题目,不难,就是有些许麻烦.对于练习还是个不错的题目. 题意就是给你两个杯子,这两个杯子的容量分别为a和b,要你通过一些操作 ...
- iOS 目录的使用
Table 1-1 Commonly used directories of an iOS app Directory Description AppName.app This is the ap ...
- Zookeeper服务常用的操作命令
Zookeeper服务安装之后,一般会在这个服务的基础之上安装其他的大数据平台,其他的框架一般会提供很多接口对Zookeeper中的内容进行一定的操作,但是功能相对单一,所以有些时候,有必要我们自己登 ...
- 关闭window 8.1 的skydrive
gpedit.msc-->计算机配置-->管理模板-->windows组件 -->skydrive-->阻止使用skydrive执行文件存储
- centos6.5Xen4.2安装
官方安装文档:http://xen.crc.id.au/support/guides/install/ 一.环境说明 1. 本文采用CentOS6.5 x64,安装开发包及开发工具. 2. 关闭sel ...