supervisor使用总结
简介:
Supervisor是一个进程控制系统。 它是一个C/S系统(注意: 其提供WEB接口给用户查询和控制)。 它允许用户去监控和控制在类UNIX系统的进程。 它的目标与launchd、daemontools和runit有些相似。 但是与它们不一样的是、它不是作为init(进程号pid是1)运行。 它是被用来控制进程、并且它在启动的时候和一般程序并无二致。 那么通俗点,它的作用是什么? 你的Nginx,Tomcat,memcache,Redis...会崩么? 那你自己写的服务器监测脚本呢? 好吧、不要再纠结了、交给Supervisor吧! 它会帮你维护这些、即使它们不小心崩了、Supervisor会帮你看住它们、维护它们。
一.安装
我的是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使用总结的更多相关文章
- asp.net core 负载均衡集群搭建(centos7+nginx+supervisor+kestrel)
概述 本文目的是搭建三台asp.net core 集群, 并配上 nginx做负载均衡 首先准备要运行的源码 http://pan.baidu.com/s/1c20x0bA 准备三台服务器(或则虚 ...
- 进程监控工具supervisor 启动Mongodb
进程监控工具supervisor 启动Mongodb 一什么是supervisor Superviosr是一个UNIX-like系统上的进程监控工具. Supervisor是一个Python开发的cl ...
- Linux Supervisor 守护进程基本配置
supervisor:C/S架构的进程控制系统,可使用户在类UNIX系统中监控.管理进程.常用于管理与某个用户或项目相关的进程. 组成部分supervisord:服务守护进程supervisorctl ...
- supervisor的安装与简单介绍
1,介绍 Supervisor是一个进程管理工具,官方的说法 用途就是有一个进程需要每时每刻不断的跑,但是这个进程又有可能由于各种原因有可能中断.当进程中断的时候我希望能自动重新启动它,此时,我就需要 ...
- supervisor监管进程max file descriptor配置不生效的问题
配置了 sudo vim /etc/security/limits.conf * soft nofile * hard nofile 单独起进程没问题, 放到supervisor下监管启动,则报错 ...
- centos 6.7 搭建tornado + nginx + supervisor的方法(已经实践)
首先,本来不想写这篇博客了,但是我测试了很多网上的例子包括简书的,全不行,我总结原因是自己太笨,搞了俩个晚上,后来决定,自己还是写一篇记录下来,保证自己以后使用 环境: centos6.7 64 py ...
- python supervisor使用
Supervisor 是基于 Python 的进程管理工具,只能运行在 Unix-Like 的系统上,也就是无法运行在 Windows 上.Supervisor 官方版目前只能运行在 Python 2 ...
- 进程管理supervisor的简单说明
背景: 项目中遇到有些脚本需要通过后台进程运行,保证不被异常中断,之前都是通过nohup.&.screen来实现,带着能否做一个start/stop/restart/reload的服务启动的想 ...
- Linux守护进程之Supervisor
1. 什么是守护进程 在linux或者unix操作系统中,守护进程(Daemon)是一种运行在后台的特殊进程,它独立于控制终端并且周期性的执行某种任务或等待处理某些发生的事件.由于在linux中,每个 ...
- supervisor 安装、配置、常用命令
前言 在 web 应用部署到线上后,需要保证应用一直处于运行状态,在遇到程序异常.报错等情况,导致 web 应用终止时,需要保证程序可以立刻重启,继续提供服务. 所以,就需要一个工具,时刻监控 web ...
随机推荐
- [leetcode121]股票买卖 Best Time to Buy and Sell Kadane算法
[题目] Say you have an array for which the ith element is the price of a given stock on day i. If you ...
- 7 Serial Configuration 理解 (一)
reference : ug470- 7 series config.pdf 7系列器件有5种配置接口,每种配置接口对应一种或者多种配置模式和总线位宽.配置时序相对于引脚的CCLK,即使在内部产生C ...
- DevExpress WinForms使用教程:图表控件 - 内置深入查询
[DevExpress WinForms v18.2下载] 在最新发布的DevExpress WinForms v18.2中,DevExpress WinForms和ASP.NET图表控件引入嵌套系列 ...
- Android开发 ---Fragment片段布局
前言 Fragment想必大家不陌生吧,在日常开发中,对于Fragment的使用也很频繁,现在主流的APP中,基本的架构也都是一个主页,然后每个Tab项用Fragment做布局,不同选项做切换,使用起 ...
- ‘’.join(列表)--列表转化为一个语句。 strip()删除掉str中的左右的空白字符
1和2相比,删除掉了str左右的空白字符,2和3相比,删除掉了上下的空白字符
- scrollIntoView()方法
该方法用于建立一个锚点,点击锚点,会跳到相应的内容,且该内容头部与浏览器头部平齐 实例: <html> <head> <title>TODO supply a ti ...
- wx小程序使用模板消息
1.直接搜索一个不存在的模板,则可以添加新模板 2.https://developers.weixin.qq.com/miniprogram/dev/api/notice.html#%E5%8F%91 ...
- 性能测试-12.Web页面性能指标与建议
1.页面加载时间 从页面开始加载到页面onload事件触发的时间.一般来说onload触发代表着直接通过HTML引用的CSS,JS,图片资源已经完全加载完毕. 2.全部页面加载时间 全部页面载入时间指 ...
- vue 路由跳转,路由传参的几种方式
1. router-link <router-link :to="{ path: 'yourPath', params: { name: 'name', dataObj: data } ...
- [转]skynet Lua中的协程
Lua中的协程 http://www.outsky.org/code/lua-coroutine.html Sep 6, 2014 Lua中的协程和其他变量一样,都是第一类值(first-class ...