supervisor是一个python编写的进程管理工具, 可以方便的管理和监控进程. supervisor分为服务端supervisord和客户端supervisorctl.

supervisor由python编写, 可以使用pip安装:

pip install supervisor

也可以使用apt-get来安装:

apt-get install supervisor

配置supervisor

在/etc/supervisor目录下可以看到supervisord的主要配置文件supervisord.conf:

; supervisor config file

[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700) [supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP) [rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket [include]
files = /etc/supervisor/conf.d/*.conf

为了便于管理, 我们将需要监控的进程写入/etc/supervisor/conf.d/*.conf中, 这些配置文件将被导入主配置文件.

新建一个blog.conf文件:

[program:blog]
directory=/home/www/Blog
command=uwsgi --ini wsgi.ini
user=www
autostart=true
autorestart=true
stdout_logfile=/home/www/Blog/log/supervisor.log

在启动blog子进程时supervisord会以user的身份在directory目录下执行command命令以启动子进程. 一般情况下, 每个program配置都要设置这三项.

autostart=true表示在supervisord启动时该子进程会自动启动. 在服务器重启后只需要重启supervisord, 不再需要一个一个地启动进程.

autoresatrt=trus表示若该子进程崩溃, supervisor会自动重启该进程.

使用supervisorctl

supervisorctrl客户端可以查看子进程的状态并进行控制:

  • supervisorctl status 查看各子进程运行状态

  • supervisorctl start <program> 根据program配置启动相应的子进程

  • supervisorctl stop <program> 停止子进程

  • supervisorctl restart <program> 重启子进程

  • supervisorctl reread 重新读入配置文件, 但不会增加新的程序

  • supervisorctl update 根据新读入配置文件, 更新程序配置

需要注意的一点是supervisor更新配置文件比较麻烦, 更新原有程序的配置需要reread - update - restart三个操作, 而添加新程序也需要reread - update - start .

进程监控工具supervisor的更多相关文章

  1. 进程监控工具supervisor 启动Mongodb

    进程监控工具supervisor 启动Mongodb 一什么是supervisor Superviosr是一个UNIX-like系统上的进程监控工具. Supervisor是一个Python开发的cl ...

  2. Supervisor – 用于 Unix 系统的进程监控工具

    Supervisor 是一个客户端/服务端模式的系统,使用户能够监视和控制 UNIX 操作系统的进程.Supervisor 为你提供一个地方来启动,停止和监视进程.进程可以单独或成组的形式控制.您还可 ...

  3. python supervisor进程监控工具的使用

    supervisor —— a process control system 另外一个类似 supervisor的工具,因为supervisor 不兼容python3, !!! Circus Proc ...

  4. 进程管理supervisor的简单说明

    背景: 项目中遇到有些脚本需要通过后台进程运行,保证不被异常中断,之前都是通过nohup.&.screen来实现,带着能否做一个start/stop/restart/reload的服务启动的想 ...

  5. 守护进程与Supervisor

    博客链接:http://www.cnblogs.com/zhenghongxin/p/8676565.html 消息队列处理后台任务带来的问题 在系统稍微大些的时候,我们经常会用到消息队列(实现的方式 ...

  6. Linux进程守护——Supervisor 使用记录

    0.旁白 Supervisor是个父进程,你要守护的进程会以Supervisor的子进程形式存在,所以老子才可以管儿子 官网链接:http://supervisord.org/ [5.参数]那块不要看 ...

  7. laravel进程管理supervisor的简单说明

    原文地址:https://www.cnblogs.com/zhoujinyi/p/6073705.html 背景: 项目中遇到有些脚本需要通过后台进程运行,保证不被异常中断,之前都是通过nohup.& ...

  8. 进程管理 supervisor

    背景知识: supervisor是用Python开发的一套通用的进程管理程序,能将一个普通的命令行进程变为后台daemon,并监控进程状态,异常退出时能自动重启. 它是通过fork/exec的方式把这 ...

  9. centos安装守护进程工具supervisor

    安装命令 yum install supervisor 启动守护进程 supervisord -c /etc/supervisord.conf 切换至/etc/supervisord.d目录下 写一个 ...

随机推荐

  1. shell 命令 查看本机ip

    ifconfig 结果有很多,查看env0的inet,就是本机的ip地址

  2. AngularJs 指令中 的Scope属性

    一.概念说明 可以是true. false .哈希对象 {} 1.true 新创建了一个作用域,且继承了父作用域:在初始化的时候,用了父作用域的属性和方法去填充我们这个新的作用域.它和父作用域不是同一 ...

  3. iOS笔记之UIKit_UIButton

    //UIButton的基本属性 _btn = [UIButton buttonWithType:UIButtonTypeCustom]; _btn.frame = CGRectMake(0, 200, ...

  4. 分形之科赫(Koch)雪花

    科赫曲线是一种分形.其形态似雪花,又称科赫雪花.雪花曲线.瑞典人科赫于1904年提出了著名的“雪花”曲线,这种曲线的作法是,从一个正三角形开始,把每条边分成三等份,然后以各边的中间长度为底边.分别向外 ...

  5. 去除DataTable指定列的重复行

    DataTable dt = ds.Tables[]; //获得 datatable DataView dv = new DataView(dt); DataTable dt2 = dv.ToTabl ...

  6. SQL2014 尝试读取或写入受保护的内存。这通常指示其他内存已损坏

    管理员身份运行 cmd ->  输入 netsh winsock reset

  7. Angular build Error:In this configuration Angular requires Zone.js

    Angular cli 运行 build后打开生成的index.html报错:In this configuration Angular requires Zone.js 生成代码如下: ng bui ...

  8. Lerning Entity Framework 6 ------ Inserting, Querying, Updating, and Deleting Data

    Creating Entities First of all, Let's create some entities to have a test. Create a project Add foll ...

  9. 564. Find the Closest Palindrome

    Given an integer n, find the closest integer (not including itself), which is a palindrome. The 'clo ...

  10. MariaDB 插入&更新&删除数据(8)

    MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可MariaDB的目的是完全兼容MySQL,包括API和命令行,MySQL由于现在闭源了,而能轻松成为MySQ ...