安装supervisord
一:简介
supervisord是一个进程管理工具,提供web页面管理,能对进程进行自动重启等操作。
优点:
- 可以将非后台运行程序后台运行
- 自动监控,重启进程
缺点:
- 不能管理后台运行程序
- 对多进程服务,不能使用kill关闭
二:安装supervisord
1.pip安装supervisord
pip install supervisor
2.生成配置文件
echo_supervisord_conf > /etc/supervisord.conf
如果报错:
vim /usr/lib/python2.6/site-packages/supervisor-3.3.3-py2.6.egg-info/requires.txt
# 注销如下内容即可
#meld3 >= 0.6.5
3.修改配置文件
[unix_http_server]
file=/tmp/supervisor.sock ; the path to the socket file
# 开启web界面
[inet_http_server] ; inet (TCP) server disabled by default
port=mweb07:9001 ; ip_address:port specifier, *:port for all iface
username=admin ; default is no username (open server)
password=123456 ; default is no password (open server)
[supervisord]
logfile=/tmp/supervisord.log ; main log file; default $CWD/supervisord.log
logfile_maxbytes=50MB ; max main logfile bytes b4 rotation; default 50MB
logfile_backups=10 ; # of main logfile backups; 0 means none, default 10
loglevel=info ; log level; default info; others: debug,warn,trace
pidfile=/tmp/supervisord.pid ; supervisord pidfile; default supervisord.pid
nodaemon=false ; start in foreground if true; default false
minfds=1024 ; min. avail startup file descriptors; default 1024
minprocs=200 ; min. avail process descriptors;default 200
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
[program:elasticsearch]
command=/data/elk/elasticsearch/bin/elasticsearch ; 管理命令,supervisor不支持后太进程
process_name=%(program_name)s
user=elk ;进程启动用户
autostart=true ;是否随supervisor启动
autorestart=true ;是否在挂了之后重启,意外关闭后会重启,比如kill掉!
startretries=3 ;启动尝试次数
stderr_logfile=/tmp/tail1.err.log ;标准输出的位置
stdout_logfile=/tmp/tail1.out.log ;标准错误输出的位置
loglevel=info ;日志的级别
[program:redis]
command=/data/elk/redis/src/redis-server /data/elk/redis/redis.conf
process_name=%(program_name)s
user=elk
directory=/data/elk/redi
4.启动关闭
启动:
supervisord -c /etc/supervisord.conf
关闭:
supervisorctl shutdown
管理命令:
supervisorctl stop program_name # 停止某一个进程,program_name 为 [program:x] 里的 x
supervisorctl start program_name # 启动某个进程
supervisorctl restart program_name # 重启某个进程
supervisorctl stop groupworker: # 结束所有属于名为 groupworker 这个分组的进程 (start,restart 同理)
supervisorctl stop groupworker:name1 # 结束 groupworker:name1 这个进程 (start,restart 同理)
supervisorctl stop all # 停止全部进程,注:start、restartUnlinking stale socket /tmp/supervisor.sock
、stop 都不会载入最新的配置文件
supervisorctl reload # 载入最新的配置文件,停止原有进程并按新的配置启动、管理所有进程
supervisorctl update # 根据最新的配置文件,启动新配置或有改动的进程,配置没有改动的进程不会受影响而重启
5.效果展示
三:安装supervisord-monitor
- supervisord-monitor是对supervisord的一个集中化管理工具,可以对supervisor统一化操作
1.安装
# 下载
git clone https://github.com/mlazarov/supervisord-monitor.git
# 生成配置文件
cd supervisord-monitor/
cp application/config/supervisor.php.example application/config/supervisor.php
2.修改配置文件,添加supervisord主机
mweb08 展示名 url 服务器地址 port 端口
$config['supervisor_servers'] = array(
'mweb08' => array(
'url' => 'http://mweb08/RPC2',
'port' => '9001',
'username' => 'admin',
'password' => '123456'
),
'mweb07' => array(
'url' => 'http://mweb07/RPC2',
'port' => '9001',
'username' => 'admin',
'password' => '123456'
),
);
3.添加nginx对supervisord-monitor的支持
server {
listen 82;
server_name localhost;
set $web_root /data/web/supervisord-monitor/public_html;
root $web_root;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $web_root$fastcgi_script_name;
fastcgi_param SCHEME $scheme;
}
}
5.展示,重启nginx后,访问即可
安装supervisord的更多相关文章
- Centos7.x 安装 Supervisord
[环境] 系统:Centos 7.3 软件:supervisord [安装Supervisord] yum install epel-release yum install -y supervisor ...
- Supervisord安装和配置
http://zhangweide.cn/archive/2013/supervisor-note.html Supervisord supervisord的出现,结束了我这苦恼的问题,它可以帮你守护 ...
- 用Supervisord管理Python进程
http://feilong.me/2011/03/monitor-processes-with-supervisord Supervisord是用Python实现的一款非常实用的进程管理工具,类似于 ...
- supervisor安装和配置
直接命令 easy_install supervisor 如果报错先安装 yum install python-setuptools,再上面一条命令: 安装成功后显示finished,我们再次进行py ...
- [linux]执行pip安装的程序:command not found
执行pip安装的程序:command not found 问题描述: 我有一台阿里云服务器,上面装的是centos系统,我用pip安装好vituralenv,都没办法直接启动.同样 我今天在部署我的t ...
- CentOS 6.X x64 编译安装 Countly
CentOS 6.X x64 编译安装Countly 安装所需的软件 yum -y install supervisor ImageMagick sendmail 1. 安装 node.js wge ...
- Linux supervisord配置使用
supervisor官方网站 http://supervisord.org 1.安装supervisord Ubuntu: $sudo apt-get install python-setuptool ...
- Supervisord管理进程实践
今天凑空研究了下Supervisord,这是一款linux进程管理工具,使用python开发,主要用于在后台维护进程(类似master守护进程),可以实现监控进程的状态.自动重启进程等操作,便于一些服 ...
- Ubuntu安装Gogs服务
花了半天的时间把阿里云的centos 换成了ubuntu 14.04 lts ,原因是因为我想安装个gogs git服务,但是centos的glibc版本太低,折腾了半天没有成功. 迁移Ghost数据 ...
随机推荐
- continue,break以及加上标签的使用(goto思路)
代码例子在java编程思想70-73页.这里只是想做做总结 java中需要用到标签的唯一理由就是因为由循环嵌套的存在,而且想从多层嵌套循环中break或者continue. 因此,标签只能放在循环前面 ...
- gcc & gdb & make 定义与区别
GCC 通常所说的GCC是GUN Compiler Collection的简称,除了编译程序之外,它还含其他相关工具,所以它能把易于人类使用的高级语言编写的源代码构建成计算机能够直接执行的二进制代码. ...
- 实践作业2:黑盒测试实践——搭建被测web系统Day 4
1.选择合适的待测web系统 2.安装web系统运行所需工具,配置运行环境 3.成功运行web系统 4.尝试Katalon测试系统
- CCF-201312-3-最大的矩形
问题描述 试题编号: 201312-3 试题名称: 最大的矩形 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 在横轴上放了n个相邻的矩形,每个矩形的宽度是1,而第i(1 ≤ ...
- 手动安装lump
教你编译PHP7 (nginx+mysql+php7) PHP7正式版已经发布,性能是PHP5.6的两倍! 操作系统: CentOS Linux, 6.5 64位服务器: 阿里云空的操作系统,我们从 ...
- TL-WR703Nv1.7刷写openwrt固件
TP-LINK TL-WR703N是一个小型的路由器,可以有线转WiFi,3G转WiFi,很多人拿它刷openwrt系统,然后可以在上面各种搞事. V1.7以前 通常刷openwrt的做法是, 下载一 ...
- struts2 谷歌浏览器保存date类型数据时报错
一同事发现一个bug,在chrome上保存一个表单时,后台会报错,而在firefox上则可以正常保存. 奇怪的地方在于,后端的程序是同一个,而在浏览器上查看请求header时,两个浏览器对应的字段内容 ...
- javascript算法题判断输入年份是否是闰年
用户输入一个年份,判断这个年是否是闰年.判断闰年条件:① 非整百年数除以4,无余为闰,有余不闰:② 整百年数除以400,无余为闰,有余不闰.比如:2000年,整百数年,就要用②公式,除以400,无余数 ...
- js(jquery)绑定点击事件
<button type="submit" id="test">test</button> 第一种 $("#test" ...
- 1267 - Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' | 1267 - Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (Latin,COERCIBL)
select * FROM information_schema.columns WHERE table_schema = "databaseName" and collation ...