简介:

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. HP Instant Information

    HP Instant Information before HP-UX 11i v3 <管理系统和工作组:HP-UX系统管理员指南> After HP-UX 11i v3 <HP-U ...

  2. 学习python二三事儿(二)

    多个变量赋值 Python允许你同时为多个变量赋值.例如: a = b = c = 1 以上实例,创建一个整型对象,值为1,三个变量被分配到相同的内存空间上. 您也可以为多个对象指定多个变量.例如: ...

  3. 关于ArrayList中的iterator返回的事迭代器实例问题。

    Arraylist是一个具体的类,它并没有定义它自己的iterator()方法,,它只是从AbstractList 这个抽象类中继承了iterator()这个方法,而AbstractList 中的it ...

  4. Nio Bio Netty Tomcat的NIO

    socket():新建一个文件 bind():绑定到端口,第一个参数就是socket()方法产生的文件描述符 listen():确定新建的这个socket是一个服务器,被动等待网络其他进程链接,参数有 ...

  5. dynamic programming:find max subarray

    public static mark dynway( ) //put or pop the books into the basket,mark the highest recorder { int ...

  6. Tomcat9配置SSL连接

    .首先生成数字证书: 使用JDK的keytool命令,生成证书(包含证书/公钥/私钥)到D:\ssl.keystore:keytool -genkey -keystore "D:\ssl.k ...

  7. 微软Power BI报表服务器学习总览

    今天,微软宣布了8月更新Power BI Report Server!此版本包含一些新功能,包括一些备受期待的项目,如报表主题,条件格式改进和报表页面工具提示. 报告 报告主题 用于触发操作的按钮 组 ...

  8. react native 第三方组件

    react native 的成功离不开优秀的第三方组件,以下是我见过的一些优秀或者有用的RN第三方组件 按钮 APSL/react-native-button 导航 react-native-simp ...

  9. Python 使用sqlalchemy操作MYSQL

    1. 安装sqlalchemy库 SQL操作引擎可能需要pymysql,故要安装如下两个程序 pip install sqlalchemy pip instal pymysql

  10. Java小故事(一)

    import java.util.Date; //导入包 public class Test11 { public static void main(String [] args){ CatFathe ...