前言

昨天临近下班,发现业务队列处理不及时,正好想到不久之前,上了一个新功能:通过队列异步转发微信消息。可能是消息太多了处理不过来,没怎么多想,处理不过来了,多增加处理进程就可以了,后来发现自己so young了 >_<!启动处理进程,必须先安装进程管理工具,比较出名的有supervisord,使用python语言实现。折腾了近半小时,后来发现自己不可能在短时间内搞定这个事情,业务上用户消息没有得到及时回复,需要快速处理,最后还是寻求公司大神帮助安装其它前端机的supervisord。为了学会安装以及使用这个神器,为了以后碰到这样的问题可以自己搞定,在测试机上尝试安装了这个神器,于是有了这篇总结的文章。

查看依赖python模块是否安装(只安装没有的依赖包)

 [root@mtest3 ~]# python -u -c "help('modules')" > a.log
[root@mtest3 ~]# cat a.log | grep element
[root@mtest3 ~]# cat a.log | grep meld
[root@mtest3 ~]# cat a.log | grep setuptool

先安装依赖包
1.elementtree-1.2.6-20050316.tar.gz

 [root@mtest3 Supervisord]# tar -xvf elementtree-1.2.-.tar.gz
[root@mtest3 Supervisord]# cd elementtree-1.2.-
[root@mtest3 elementtree-1.2.-]# python setup.py install

2.meld3-0.6.5.tar.gz

 [root@mtest3 Supervisord]# tar -xvf meld3-0.6..tar.gz
[root@mtest3 Supervisord]# cd meld3-0.6.
[root@mtest3 meld3-0.6.]# python setup.py install

3.setuptools-20.2.2.tar.gz

 [root@mtest3 Supervisord]# tar -xvf setuptools-20.2..tar.gz
[root@mtest3 Supervisord]# cd setuptools-20.2.
[root@mtest3 setuptools-20.2.]# python setup.py install

3.安装supervisord

 [root@mtest3 Supervisord]# tar -xvf supervisor-3.2..tar.gz
[root@mtest3 Supervisord]# cd supervisor-3.2.
[root@mtest3 supervisor-3.2.]# python setup.py install Installing echo_supervisord_conf script to /usr/bin
Installing pidproxy script to /usr/bin
Installing supervisorctl script to /usr/bin
Installing supervisord script to /usr/bin

生成配置文件

  [root@mtest3 ~]# echo_supervisord_conf > /u01/server/supervisord/conf/supervisord.conf 

设置

 ; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
; [unix_http_server]
file=/u01/server/supervisord/temp/supervisor.sock ; (the path to the socket file) [supervisord]
logfile=/u01/server/supervisord/logs/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups= ; (num of main logfile rotation backups;default )
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/u01/server/supervisord/temp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)
minfds= ; (min. avail startup file descriptors;default )
minprocs= ; (min. avail process descriptors;default ) ; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl]
serverurl=unix:///u01/server/supervisord/temp/supervisor.sock ; use a unix:// URL for a unix socket ; The below sample program section shows all possible program subsection values,
; create one or more 'real' program: sections to be able to control them under
; supervisor. [program:wx_front]
command=/u01/server/php/bin/php /u01/server/apps/wechat/artisan queue:listen --queue=wxqueue --timeout= --delay= --memory= --sleep= --tries= --env=test ; the program (relative uses PATH, can take args)
process_name=%(program_name)s ; process_name expr (default %(program_name)s)
numprocs= ; number of processes copies to start (def )
;directory=/tmp ; directory to cwd to before exec (def no cwd)
;umask= ; umask for process (default None)
;priority= ; the relative start priority (default )
autostart=true ; start at supervisord start (default: true)
startsecs= ; # of secs prog must stay up to be running (def. )
startretries= ; max # of serial start failures when starting (default )
;autorestart=unexpected ; when to restart if exited after running (def: unexpected)
;exitcodes=, ; 'expected' exit codes used with autorestart (default ,)
;stopsignal=QUIT ; signal used to kill process (default TERM)
;stopwaitsecs= ; max num secs to wait b4 SIGKILL (default )
;stopasgroup=false ; send stop signal to the UNIX process group (default false)
;killasgroup=false ; SIGKILL the UNIX process group (def false)
user=daemon ; setuid to this UNIX account to run the program
;redirect_stderr=true ; redirect proc stderr to stdout (default false)
stdout_logfile=/u01/server/supervisord/logs/wx_front_stdout.log ; stdout log path, NONE for none; default AUTO
stdout_logfile_maxbytes=50MB ; max # logfile bytes b4 rotation (default 50MB)
stdout_logfile_backups= ; # of stdout logfile backups (default )
;stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default )
;stdout_events_enabled=false ; emit events on stdout writes (default false)
stderr_logfile=/u01/server/supervisord/logs/wx_front_stderr.log ; stderr log path, NONE for none; default AUTO
stderr_logfile_maxbytes=50MB ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups= ; # of stderr logfile backups (default )
;stderr_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default )
;stderr_events_enabled=false ; emit events on stderr writes (default false)
;environment=A="",B="" ; process environment additions (def no adds)
;serverurl=AUTO ; override serverurl computation (childutils) [program:wx_admin]
command=/u01/server/php/bin/php /u01/server/apps/admin/artisan queue:listen --queue=wx_queue_admin --timeout= --delay= --memory= --sleep= --tries= --env=test ; the program (relative uses PATH, can take args)
process_name=%(program_name)s ; process_name expr (default %(program_name)s)
numprocs= ; number of processes copies to start (def )
autostart=true ; start at supervisord start (default: true)
startsecs= ; # of secs prog must stay up to be running (def. )
startretries= ; max # of serial start failures when starting (default )
user=daemon ; setuid to this UNIX account to run the program
stdout_logfile=/u01/server/supervisord/logs/wx_admin_stdout.log ; stdout log path, NONE for none; default AUTO
stdout_logfile_maxbytes=50MB ; max # logfile bytes b4 rotation (default 50MB)
stdout_logfile_backups= ; # of stdout logfile backups (default )
stderr_logfile=/u01/server/supervisord/logs/wx_admin_stderr.log ; stderr log path, NONE for none; default AUTO
stderr_logfile_maxbytes=50MB ; max # logfile bytes b4 rotation (default 50MB)

开机自启动
/etc/rc.local
supervisord -c /u01/server/supervisord/conf/supervisord.conf

手动启动
supervisord -c /u01/server/supervisord/conf/supervisord.conf

进程管理
1.进入cli终端

[root@mtest3 logs]# supervisorctl -c /u01/server/supervisord/conf/supervisord.conf
supervisor>

2.查看进程状态

 supervisor> status
wx_admin: RUNNING pid , uptime ::
wx_admin: RUNNING pid , uptime ::
wx_front: RUNNING pid , uptime ::
wx_front: RUNNING pid , uptime ::

3.重启superivsord服务(更改配置之后)

supervisor> reload
Really restart the remote supervisord process y/N? y
Restarted supervisord

4.关闭进程

 supervisor> stop all
wx_admin:: stopped
wx_admin:: stopped
wx_front:: stopped
wx_front:: stopped

5.启动进程

 supervisor> start all
wx_admin:: started
wx_admin:: started
wx_front:: started
wx_front:: started

6.查看命令行帮助(支持的命令,以及用法)

 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

7.退出

 supervisor> exit

 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

备注
1.配置key value必须至少包含一个空格再跟上 ; 注释符号

后记

看起来安装这个很简单,实际操作过之后,还是碰到一些意外的坑,而这些坑只有实际操作过才能发现:)

参考资料
[1] supervisord官网
http://supervisord.org/index.html

[2] supervisor github

https://github.com/Supervisor/supervisor/releases

[3] elementtree-1.2.6-20050316
http://effbot.org/downloads#elementtree

[4] meld3-0.6.5
http://www.plope.com/software/meld3/

[5] setuptools-20.2.2
https://pypi.python.org/pypi/setuptools#downloads

supervisord进程管理工具小结的更多相关文章

  1. Supervisord进程管理工具

    进程管理工具Supervisord Posted on 2014/06/17 by admin Supervisord 上面已经介绍了Go目前是有两种方案来实现他的daemon,但是官方本身还不支持这 ...

  2. Linux 进程管理工具 supervisord 安装及使用

    Supervisor是用Python实现的一款非常实用的进程管理工具 1.安装过程非常简单 安装python 安装meld3-0.6.8.tar.gz 安装supervisor-3.0a12.tar. ...

  3. Linux进程管理工具 Supervisord 的安装 及 入门教程

    Supervisor是一个进程管理工具,官方的说法: 用途就是有一个进程需要每时每刻不断的跑,但是这个进程又有可能由于各种原因有可能中断.当进程中断的时候我希望能自动重新启动它,此时,我就需要使用到了 ...

  4. 2017.7.21 linux下进程管理工具supervisord的安装与使用

    参考来自:http://blog.haohtml.com/archives/15145 0 操作环境 1 supervisord的介绍 Supervisord是用Python实现的一款非常实用的进程管 ...

  5. 进程管理工具-Supervisord 使用

    简介 Supervisor 是一个用 Python 写的进程管理工具,可以很方便的用来在 UNIX-like 系统(不支持 Windows)下启动.重启(自动重启程序).关闭进程(不仅仅是 Pytho ...

  6. Linux进程管理工具——supervisor

    介绍 Supervisord是用Python实现的一款非常实用的进程管理工具 安装 这里用源码 supervisor-.tar.gz .tar.gz cd supervisor- sudo pytho ...

  7. supervisor python开发的进程管理工具

    Supervisor (http://supervisord.org) 是一个用 Python 写的进程管理工具,可以很方便的用来启动.重启.关闭进程(不仅仅是 Python 进程).除了对单个进程的 ...

  8. supervisor进程管理工具的使用

    supervisor是一款进程管理工具,当想让应用随着开机启动,或者在应用崩溃之后自启动的时候,supervisor就派上了用场. 广泛应用于服务器中,用于引导控制程序的启动 安装好superviso ...

  9. Python 进程管理工具 Supervisor 使用教程

    Supervisor 是基于 Python 的进程管理工具,只能运行在 Unix-Like 的系统上,也就是无法运行在 Windows 上.Supervisor 官方版目前只能运行在 Python 2 ...

随机推荐

  1. applicationContext.xml配置AOP切面编程

    Computer.java package com.wh.aop2; public class Computer { public void play01(){ System.out.println( ...

  2. 324 Wiggle Sort II 摆动排序 II

    给定一个无序的数组nums,将它重新排列成nums[0] < nums[1] > nums[2] < nums[3]...的顺序.例子:(1) 给定nums = [1, 5, 1, ...

  3. [转]linux grep命令

    转自:http://www.cnblogs.com/end/archive/2012/02/21/2360965.html 1.作用Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表 ...

  4. P3368 【模板】树状数组 2(树状数组维护差分序列)

    题目描述 如题,已知一个数列,你需要进行下面两种操作: 1.将某区间每一个数数加上x 2.求出某一个数的和 输入输出格式 输入格式: 第一行包含两个整数N.M,分别表示该数列数字的个数和操作的总个数. ...

  5. win32之bitmap篇

    先讲一下LoadBitmap的用法,代码如下: PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd,&ps); HDC hMemDC = CreateCompa ...

  6. Appium Python API 汇总

    最近在学习Python自动化,网络搜集而来,留着备用, 方便自己也方便他人.感谢总结的人! 1.contexts contexts(self): Returns the contexts within ...

  7. 【译】x86程序员手册16-5.3联合使用段与分页转换

    5.3 Combining Segment and Page Translation  联合使用段与分页转换 Figure 5-12 combines Figure 5-2 and Figure 5- ...

  8. gtest ASSERT_TRUE和EXPECT_TRUE

    调用ASSERT_TRUE的函数,返回值类型定义必须是void,如果想返回别的类型,就用EXPECT_TRUE: void abc::fun() { ASSERT_TRUE(fun1()); } bo ...

  9. Python 之读取大文件readline与readlines的差别

    import time def get_all_lines(filename): start_time = time.time() try: f = open(filename, 'rb') exce ...

  10. 惊了!!! 小白零基础学java (月薪过万是你的梦想嘛) 手把手教学 就怕你不动手【二十五】第二章【初识MySQL】

    初识MySQL1. 了解主流的数据库和数据库分类1.1 数据库概念数据库:按照数据结构来组织.存储和管理数据的一种建立在计算机存储设备上的仓库. 数据库的优势: 1. 可以持久化存储大量的数据.方便我 ...