supervisor process management
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的更多相关文章
- Java Business Process Management(业务流程管理) 初识环境搭建
一.简介 (一)什么是jbpm JBPM,全称是Java Business Process Management(业务流程管理),它是覆盖了业务流程管理.工作流.服务协作等领域的一个开源的.灵活的.易 ...
- Performance Tuning Using Linux Process Management Commands
[root@bigdata-server-02 /]# ps --help all Usage: ps [options] Basic options: -A, -e all processes -a ...
- Linux Process Management && Process Scheduling Principle
目录 . 引言 . 进程优先级 . 进程的生命周 . 进程表示 . 进程管理相关的系统调用 . 进程调度 . 完全公平调度类 . 实时调度类 . 调度器增强 . 小结 1. 引言 在多处理器系统中,可 ...
- <<Linux kernel development>> Process Management
The Process On modern operating systems,processes provide two virtualizations:a virtualized processo ...
- linux process management
CREAT PROCESS fork() | clone(參数,决定父子函数的共享内容) | do_fork() | copy_process() | dup_task_struct() 创建子进程的 ...
- csharp:workflow and bpm(Business Process Management)
http://ccflow.codeplex.com/ http://winwf.codeplex.com/ http://nginn.codeplex.com/ https://github.com ...
- Process management of windows
igfxem.exe进程是正常的进程.是intel家的核显驱动类的进程.核显即"核芯显卡",是指GPU部分它是与CPU建立在同一内核芯片上,两者完全融合的芯片."核芯显卡 ...
- Project Management Process
Project Management ProcessDescription .............................................................. ...
- supervisor:How is this different from daemontools ?
"daemontools has too much focus on security as opposed to being a process manager for my taste. ...
随机推荐
- [转][Oracle]常见报错及处理
IIS 在安装 Oracle Client 后,需要命令行执行: iisreset 1.ORA-00257 参考自:https://jingyan.baidu.com/article/f71d6037 ...
- 阿里云线上ROS静态路由转发,有大坑。
原因见上去,阿里云不支持VPC中转流量,VPC1和VPC2都在国内,VPC3在香港,如果按阿里云的做法,必须付费2次国际隧道的钱,才可以实现三个VPC互通.明显很浪费钱. 所以我们只能在三个VPC,各 ...
- [UE4]在当前角色正前方2米处生成一个Actor
- 使用Bootstrap 基于MVC输出移动化table 列表
基于Bootrap的列表组及栅格布局来实现 模型定义 public class StreetEvent { public int Id { get; set; } public string Stre ...
- Shiro Realm
Realm: 在实际应用中,shiro从数据库中获取安全数据(如用户.角色.权限),而不是从ini中,可作为安全数据源 即SecurityManager要验证用户身份,那么它需要从Realm获取相应的 ...
- vue2.0-组件传值
父组件给子组件传值,子组件用props接收 例子:两个组件,一个是父组件标签名是parent,一个是子组件标签名是child,并且child组件嵌套在父组件parent里,大概的需求是:我们子组件里需 ...
- python中的sockeserver模块简单实用
1. socketserver模块简介 在python的socket编程中,实用socket模块的时候,是不能实现多个连接的,当然如果加入其它的模块是可以的,例如select模块,在这里见到的介绍下s ...
- 【接口测试】【SOAP】简单的接口测试学习
==================================================================================================== ...
- PHP的几种缓存方式
1.文件缓存: 2.Memcached; 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的 ...
- fabric-network_setup.sh安装脚本分析
在进行镜像安装前,提供了一个sample脚本的下载,可以使用该脚本进行容器的启停.这里对该脚本进行分析. fabric/release/linux-amd64/network_setup.sh 脚本提 ...