简介:

Supervisor是一个进程控制系统。 它是一个C/S系统(注意: 其提供WEB接口给用户查询和控制)。 它允许用户去监控和控制在类UNIX系统的进程。 它的目标与launchd、daemontools和runit有些相似。 但是与它们不一样的是、它不是作为init(进程号pid是1)运行。 它是被用来控制进程、并且它在启动的时候和一般程序并无二致。 那么通俗点,它的作用是什么? 你的Nginx,Tomcat,memcache,Redis...会崩么? 那你自己写的服务器监测脚本呢? 好吧、不要再纠结了、交给Supervisor吧! 它会帮你维护这些、即使它们不小心崩了、Supervisor会帮你看住它们、维护它们。

官网http://supervisord.org

 

一.安装

我的是CentOS Linux release 7.2.1511 所以就直接用yum install -y supervisor的方式来安装了

 

二.修改配置/etc/supervisor.conf

[unix_http_server]

file=/tmp/supervisor.sock   ; (the path to the socket file)

chmod=0777                 ; sockef file mode (default 0700)

[inet_http_server]         ; inet (TCP) server disabled by default (注意[inet_http_server]  前面的分号要去掉)

port=127.0.0.1:9001        ; (ip_address:port specifier, *:port for all iface)

[supervisorctl]

serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL  for a unix socket (注意前面是unix://)

serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket

 

三.启动过程中碰到的问题

启动

supervisord -c /etc/supervisord.conf

supervisorctl -c /etc/supervisord.conf

(

通过配置文件来启动supervisor,然后再使用supervisorctl, supervisord &supervisorctl是supervisor的两个可执行程序,其关系相当于Apache的httpd和apachectl;

supervisord是后台管理服务器,用来依据配置文件的的策略管理后台守护进程,会随系统自动启动。

supervisorctl用于管理员向后台管理员发送启动/重启/停止 等指令

)

问题1:

[root@localhost sunallies-pvm-center-refactor]# supervisorctl reload

error: <class 'socket.error'>, [Errno 111] Connection refused: file: /usr/lib64/python2.7/socket.py line: 571

没有启动supervisor的后台管理程序

supervisord -c /etc/supervisord.conf

supervisorctl -c /etc/supervisord.conf

 

问题2:

[root@localhost sunallies-pvm-center-refactor]# supervisorctl

http://127.0.0.1:9001 refused connection

如果已经开启supervisor(没启动也会有这种提示)且启用了127.0.0.1:9001端口则确认是否已经将[inet_http_server]前面的分号去掉

 

四.使用

1在[include]下添加定时任务的配置管理文件

[include]

files = supervisord.d/*.conf

例如我的一个laravel队列监控任务的配置如下:

/etc/supervisor/supervisord.d/pvm-api-queue.conf

[program:pvm-api-redis-queue-listener]    //程序名称,加粗部分可随便定义

process_name=%(program_name)s_%(process_num)02d

command=php /home/www/sunallies-pvm-api/artisan queue:work --queue pvm.api.profits  --sleep=1 --tries=3 --daemon     //任务的执行路径

autostart=true

autorestart=true

user=root

numprocs=2 //处理程序所使用的cpu进程数量

redirect_stderr=true

stdout_logfile=/home/www/sunallies-pvm-api/storage/logs/worker.log

[program:pvm-api-redis-warning-queue-listener]

process_name=%(program_name)s_%(process_num)02d

command=php /home/www/sunallies-pvm-api/artisan queue:work --queue pvm.warning  --sleep=1 --tries=3 --daemon

autostart=true

autorestart=true

user=root

numprocs=1

redirect_stderr=true

stdout_logfile=/home/www/sunallies-pvm-api/storage/logs/worker.log

[program:pvm-api-redis-makePlantEnergy-queue-listener]

process_name=%(program_name)s_%(process_num)02d

command=php /home/www/sunallies-pvm-api/artisan queue:work --queue pvm.api.makePlantEnergy --sleep=1 --tries=3 --daemon

autostart=true

autorestart=true

user=root

numprocs=3

redirect_stderr=true

stdout_logfile=/home/www/sunallies-pvm-api/storage/logs/worker.log

 

修改或者添加后台任务程序或者supervisor配置之后需要重新加载(reload)【最好重新启动(restart)】supervisor

 

laravel queue详细说明https://www.lijinma.com/blog/2017/01/31/laravel-queue/

参考文档https://laravel-china.org/topics/2126/supervisor-installation-configuration-use

supervisor使用总结的更多相关文章

  1. asp.net core 负载均衡集群搭建(centos7+nginx+supervisor+kestrel)

    概述 本文目的是搭建三台asp.net core 集群, 并配上 nginx做负载均衡   首先准备要运行的源码 http://pan.baidu.com/s/1c20x0bA 准备三台服务器(或则虚 ...

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

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

  3. Linux Supervisor 守护进程基本配置

    supervisor:C/S架构的进程控制系统,可使用户在类UNIX系统中监控.管理进程.常用于管理与某个用户或项目相关的进程. 组成部分supervisord:服务守护进程supervisorctl ...

  4. supervisor的安装与简单介绍

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

  5. supervisor监管进程max file descriptor配置不生效的问题

    配置了 sudo vim /etc/security/limits.conf * soft nofile * hard nofile   单独起进程没问题, 放到supervisor下监管启动,则报错 ...

  6. centos 6.7 搭建tornado + nginx + supervisor的方法(已经实践)

    首先,本来不想写这篇博客了,但是我测试了很多网上的例子包括简书的,全不行,我总结原因是自己太笨,搞了俩个晚上,后来决定,自己还是写一篇记录下来,保证自己以后使用 环境: centos6.7 64 py ...

  7. python supervisor使用

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

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

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

  9. Linux守护进程之Supervisor

    1. 什么是守护进程 在linux或者unix操作系统中,守护进程(Daemon)是一种运行在后台的特殊进程,它独立于控制终端并且周期性的执行某种任务或等待处理某些发生的事件.由于在linux中,每个 ...

  10. supervisor 安装、配置、常用命令

    前言 在 web 应用部署到线上后,需要保证应用一直处于运行状态,在遇到程序异常.报错等情况,导致 web 应用终止时,需要保证程序可以立刻重启,继续提供服务. 所以,就需要一个工具,时刻监控 web ...

随机推荐

  1. [Leetcode 101]判断对称树 Symmetric Tree

    [题目] Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). ...

  2. 第二节 java流程控制(判断结构+选择结构)

    Java的判断结构: 1.if(条件表达式){ 执行语句 }: 2.if(条件表达式){ 执行语句 }else{ 执行语句 } 3. if(条件表达式){ 执行语句 }else if(条件表达式){ ...

  3. DevExpress WinForms v18.2新版亮点(二)

    行业领先的.NET界面控件2018年第二次重大更新——DevExpress v18.2日前正式发布,本站将以连载的形式为大家介绍各版本新增内容.本文将介绍了DevExpress WinForms v1 ...

  4. django面试题必知

    Django的Model的继承有几种形式,分别是什么?(私信小编001 .002 .003 .007任何一个即可获取Python学习资料) 一.抽象继承: 这种继承的定义方法如下: 上例中,我们的Hu ...

  5. java学习笔记17(Calendarl类)

    Calendar类:(日历) 用法:Calendar是一个抽象类:不能实例化(不能new),使用时通过子类完成实现,不过这个类不需要创建子类对象,而是通过静态方法直接获取: 获取对象方法:getIns ...

  6. 登陆网页模板 - 1 (HTML+CSS)

    一个用HTML和CSS写的简单登录页面,主要是用CSS来进行修饰美化的 这个登陆界面有输入账号和密码的表单,还有登陆和注册两个按键,点击按键分别会输出“您已成功登陆,稍后会跳转到您需要的页面~”,“您 ...

  7. [转]How rival bots battled their way to poker supremacy

    How rival bots battled their way to poker supremacy http://www.nature.com/news/how-rival-bots-battle ...

  8. [转]ZooKeeper 集群环境搭建 (本机3个节点)

    ZooKeeper 集群环境搭建 (本机3个节点) 是一个简单的分布式同步数据库(或者是小文件系统) ------------------------------------------------- ...

  9. Linux 对文件进行加密存放

    /********************************************************************** * Linux 对文件进行加密存放 * 说明: * Gi ...

  10. 【linux基础】V4L2介绍

    参考 1. https://www.cnblogs.com/hzhida/archive/2012/05/29/2524351.html 2. https://www.cnblogs.com/hzhi ...