简介:

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. node(1) npm是什么?node的异步概念

    NPM是随同的NodeJS一起安装的包管理工具 他可以做什么? 1.可以从NPM服务器下载别人的东西使用 2.可以把自己的东西传到NPM服务器,让别人下载使用 淘宝的镜像会快一点      cnpm ...

  2. jq demo—图片翻页展示效果 animate()动画

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  3. Android system :led_class驱动

    一.代码: leds_4412.c #include <linux/kernel.h> #include <linux/module.h> #include <linux ...

  4. jsch上传文件到服务器

    需求就是上传文件到服务器,服务器的存储地址由程序决定然后可以自动创建. 使用第三方:jsch JSch 是SSH2的一个纯Java实现.它允许你连接到一个sshd 服务器,使用端口转发,X11转发,文 ...

  5. POJ - 3252 A - Round Numbers

    The cows, as you know, have no fingers or thumbs and thus are unable to play Scissors, Paper, Stone' ...

  6. Linux文件系统命令 mv

    命令名:mv 功能:移动一个文件,从一个位置到另外一个位置. 用法:mv source_dir dist_dir eg: renjg@renjg-HP-Compaq-Pro--MT:/var/tmp$ ...

  7. java 移动开发获取多级下拉框json数据的类和mobile-select-area插件

    我这里以行政区划做例子 //这个类是把数据库中的行政区划转化为json格式的data @SuppressWarnings("rawtypes")public class XzqhL ...

  8. [SpringMVC-初始] 初始SpringMVC

    关于SpringMVC的简介 A.SpringMVC概述 作用: SpringMVC框架是SpringFramWork中实现了MVC架构模式的轻量级子框架 用于将WEB层进行职责解耦,松散的耦合可插拔 ...

  9. C:基础知识

      基础知识 一.基础转义字符 1.常用的转义字符 \n 回车换行 (10) \” 双引号 \t 横向跳格(9) \0 空字符(0) \v 竖向跳格 (11) \a 响铃(7) \b 退格 (8) \ ...

  10. ios 手机验证码用户注册(倒计时15秒)

    // // ViewController.m // register手机验证码注册 // // Created by zzqqrr on 17/8/28. // Copyright (c) 2017年 ...