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 ...
随机推荐
- nginx 下 bootstrap fa 字体异常问题
server { listen 8082; # server_name 192.168.16.88; # root /home/ywt/workspace/kuF/web/statics; # aut ...
- python——常用功能之文本处理
前言 在生活.工作中,python一直都是一个好帮手.在python的众多功能中,我觉得文本处理是最常用的.下面是平常使用中的一些总结.环境是python 3.3 0. 基础 在python中,使用s ...
- Isomorphic Strings
Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the chara ...
- Griddle, griddle-react 一个REACT 表格组件
Griddle, griddle-react 一个REACT 表格组件: http://griddlegriddle.github.io/Griddle/index.html
- Selenium2(webdirver)入门之环境搭建(Java版)
一.开发环境: 1.JDK1.6 2.Eclipse:Version: Kepler Service Release 1,下载地址:http://www.eclipse.org/downloads/ ...
- 【转载】通过JDBC对MySQL数据库的增删改查
通过JDBC进行简单的增删改查(以MySQL为例) 目录 前言:什么是JDBC 一.准备工作(一):MySQL安装配置和基础学习 二.准备工作(二):下载数据库对应的jar包并导入 三.JDBC基本操 ...
- 解读Unity中的CG编写Shader系列五(理论知识)
转自 http://www.itnose.net/detail/6098474.html 经过前面的系列文章中的三个例子,尽管代码简单,但是我想应该还有些地方没有100%弄明白,我们现在得回过头来补充 ...
- iOS UILocalNotification 每2周,每两个月提醒
iOS 的UILocalNotification提醒提供了默认的重复频率,比如,一天,一个星期等等,但是对于非标准的频率,比如每,2周,每2个月,无法重复提醒. 我们的思路是在应用程序开始时,把即将发 ...
- ui router 介绍
1. 路由规则 rap框架页面路由基于ui-router实现 1.1 ui-router 一个基本的路由状态如下所示: 路由配置: $stateProvider .state('po',{ url:' ...
- MySQL 四种事务隔离级的说明
很早之前写的文章,重新回顾和学习下: 按照SQL:1992 事务隔离级别,InnoDB默认是可重复读的(REPEATABLE READ).MySQL/InnoDB 提供SQL标准所描述的所有四个事务隔 ...