supervisor是unix like系统的进程管理工具

安装:

pip install supervisor

配置文件:

echo_supervisord_conf # 打印一个配置文件样例
echo_supervisord_conf > /etc/supervisord.conf # 在/etc目录生成配置文件

编辑配置文件supervisord.conf,取消include部分注释,修改files配置项指向的路径

[include]
files = /etc/supervisor/*.conf # /an/absolute/filename.conf /an/absolute/*.conf foo.conf config??.conf # 使用这个部分可以将不同的配置文件拆分

创建单独的程序配置文件:

mkdir /etc/supervisor  # 建立另一个文件夹,用于放置配置文件
cd /etc/supervisor
touch test.conf

在test.conf写入下面的配置信息,可以在一个文件配置多个程序,也可以将多个程序分在不同文件:

[program:test]
; 程序文件的目录
directory=/home/think/
; 运行程序的命令
command=python test.py
user=think # 用户名
;下面部分先不用管
autostart=true
autorestart=true
redirect_stderr=true
stopsignal=TERM
stopasgroup=true

[program:celery_producer_consumer_res]
directory=/home/buxizhizhoum/1-Work/2-Codes/celery/producer_consumer
command=python producer_consumer.py -app %(process_num)s
numprocs=1
numprocs_start=10
process_name=%(program_name)s_%(process_num)s
autorestart=true
startsecs=3
startretries=3
stdout_logfile=/tmp/%(program_name)s_%(process_num)s.log
stdout_logfile_maxbytes=20MB
stdout_logfile_backups=1

在上面配置文件的directory项指定的目录,新建test.py文件,写入要运行的程序,此处写入的示例程序为:

#!/usr/bin/python
# -*- coding: utf-8 -*-
import datetime
import time
import sys while True:
print >>sys.stdout, datetime.datetime.now() # 只使用print不会在后续使用supervisorctl tail命令时显示程序输出
sys.stdout.flush()
time.sleep(1)

启动:

supervisord

or

supervisord -c /filename/of/your/config/file.conf

这时如果配置正确,配置文件中配置的进程应该已经启动

查看:

supervisorctl status

log在/tmp/supervisord.log

其它:

supervisorctl stop <program name>  # stop program
supervisorctl start <program name>
supervisorctl reload <program name> # 重新加载配置
supervisorctl tail <program name> # 获取程序输出,print的输出不会被获取,只输出sys.stdout, sys.stderr

管理一组程序:

[group:celery_task_summary]
;programs=progname1,progname2 ; each refers to 'x' in [program:x] definitions
programs=celery_tasks ; each refers to 'x' in [program:x] definitions
;priority=
supervisorctl update
supervisorctl restart celery_task_summary: # 重启程序组
supervisorctl restart celery_task_summary:celery_tasks # 重启程序组里面的一个, 添加程序组后 supervisorctl restart celery_tasks 已经不能使用

网页监控:

在之前的配置文件中下面两行的注释取消:

[inet_http_server]
port=127.0.0.1:

使用浏览器访问 http://127.0.0.1:9001

supervisor process management的更多相关文章

  1. Java Business Process Management(业务流程管理) 初识环境搭建

    一.简介 (一)什么是jbpm JBPM,全称是Java Business Process Management(业务流程管理),它是覆盖了业务流程管理.工作流.服务协作等领域的一个开源的.灵活的.易 ...

  2. Performance Tuning Using Linux Process Management Commands

    [root@bigdata-server-02 /]# ps --help all Usage: ps [options] Basic options: -A, -e all processes -a ...

  3. Linux Process Management && Process Scheduling Principle

    目录 . 引言 . 进程优先级 . 进程的生命周 . 进程表示 . 进程管理相关的系统调用 . 进程调度 . 完全公平调度类 . 实时调度类 . 调度器增强 . 小结 1. 引言 在多处理器系统中,可 ...

  4. <<Linux kernel development>> Process Management

    The Process On modern operating systems,processes provide two virtualizations:a virtualized processo ...

  5. linux process management

    CREAT PROCESS fork() | clone(參数,决定父子函数的共享内容) | do_fork() | copy_process() | dup_task_struct() 创建子进程的 ...

  6. csharp:workflow and bpm(Business Process Management)

    http://ccflow.codeplex.com/ http://winwf.codeplex.com/ http://nginn.codeplex.com/ https://github.com ...

  7. Process management of windows

    igfxem.exe进程是正常的进程.是intel家的核显驱动类的进程.核显即"核芯显卡",是指GPU部分它是与CPU建立在同一内核芯片上,两者完全融合的芯片."核芯显卡 ...

  8. Project Management Process

    Project Management ProcessDescription .............................................................. ...

  9. supervisor:How is this different from daemontools ?

    "daemontools has too much focus on security as opposed to being a process manager for my taste. ...

随机推荐

  1. HTML和SEO基础知识:H标签全透视

    原文地址:http://www.chinaz.com/web/2010/0921/134391.shtml 什么是H标签? h1,h2,h3,h4,h5,h6,作为标题标签,并且依据重要性递减.我认为 ...

  2. Ajax的课外了解

    Ajax传入的数据的话,只能是字符串或数字,字段,其他形式的传参都不可以: Ajax只是跟后台交互也有同源策略的限制: 不是当前服务器叫跨域: Ajax也有同源策略的限制想做跨域处理,只能通过scri ...

  3. rabbitmq的vhost与用户管理(转)

    原文地址:https://blog.csdn.net/leisure_life/article/details/78707338 当我们在创建用户时,会指定用户能访问一个虚拟机,并且该用户只能访问该虚 ...

  4. vue 路由 以及默认路由跳转

    https://router.vuejs.org/ vue路由配置: 1.安装 npm install vue-router --save / cnpm install vue-router --sa ...

  5. 一次线上zabbix server 挂掉的思考

    突然间发现zabbix 挂了,咋发现的呢?报警的世界突然安静了,你就会觉得不妥了.这是运维人员的通病,有报警嫌烦,没报警心里会不安.1,图形界面上确实显示zabbix server is not ru ...

  6. Zabbix利用orabbix插件监控Oracle数据库

    一.jdk的安装(Orabbix Server) 1.软件解压,放到固定位置 1 2 tar zxf jdk-8u51-linux-x64.tar.gz mv jdk1.8.0_51/ /usr/lo ...

  7. sed初学者实用说明

     转自:http://www.codeweblog.com/sed%E5%88%9D%E5%AD%A6%E8%80%85%E5%AE%9E%E7%94%A8%E8%AF%B4%E6%98%8E/ ...

  8. Linux coredump 的打开和关闭

    (转载自 http://blog.sina.com.cn/s/blog_6b3765230100lazj.html) ulimit -c 输出如果为0,则说明coredump没有打开 ulimit - ...

  9. cocos源码分析--ClippingNode绘图原理

    在OpenGL 绘制过程中,与帧缓冲有关的是模版,深度测试,混合操作.模版测试使应用程序可以定义一个遮罩,在遮罩内的片段将被保留或者丢弃,在遮罩外的片段操作行为则相反.深度测试用来剔除那些被场景遮挡的 ...

  10. cocos子节点转父节点坐标 原理浅析(局部坐标转世界坐标同理)

    在CCNode的类中,有一个得到 一个节点坐标系转换父亲坐标系的一个矩阵,节点内坐标乘以这个矩阵,就可以转换为在节点父节点中的坐标,方法名为: Mat4& Node::getNodeToPar ...