安装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数据 ...
随机推荐
- 网页的居中显示,使用了margin、clear:both
很久没写过页面了,现在写起来也觉得捡起来还是挺快的. 当时遇到了这样的问题,我有一个大的div包涵了整个网站,有网页头部,中部还有底部.头部就是一个标题,中部就是几张图片跟文字排版,结果左右两边的图片 ...
- ShoneSharp语言(S#)的设计和使用介绍系列(2)— 掀开盖头
ShoneSharp语言(S#)的设计和使用介绍 系列(2)- 掀开盖头 作者:Shone 声明:原创文章欢迎转载,但请注明出处,https://www.cnblogs.com/ShoneSharp. ...
- DIV居中的经典方法
1. 实现DIV水平居中 设置DIV的宽高,使用margin设置边距0 auto,CSS自动算出左右边距,使得DIV居中. 1 div{ 2 width: 100px; 3 height: 100px ...
- Android 项目使用TensorFlow
Android 项目使用TensorFlow 首先需要搭建TensorFlow编译环境 参考:(http://www.cnblogs.com/dyufei/p/8027764.html) Tensor ...
- Java分布式锁实现详解
在进行大型网站技术架构设计以及业务实现的过程中,多少都会遇到需要使用分布式锁的情况.那么问题也就接踵而至,哪种分布式锁更适合我们的项目? 下面就这个问题,我做了一些分析: 分布式锁现状: 目前几乎很多 ...
- UWP 实现App多语言为所欲为切换
为所欲为,嗯 话不多说,先看效果吧(事先说明,我的方法不是最好的,但是我用着最有效.) [吐槽一下博客园上传的图片,我的App敲鸡漂亮滴,自带亚克力效果,怎么图片上传上来这么多的噪点啊.] [ 商店地 ...
- tensorflow 安装升级
对于已经安装过的tensorflow,执行以下命令升级到最新版: pip3 install -U tensorflow 目前最新版本1.4
- HTMLCSS实现左侧固定宽度右侧内容可滚动
在做移动端页面的时候,经常会碰到一个div中分左右两个div,左侧div固定宽度或百分比,右侧div中内容左右溢出,需要左右滑动才可以浏览到全部内容,为此写了一个demo. 处理这个问题的核心关键点是 ...
- python 3.6 urllib库实现天气爬取、邮件定时给妹子发送天气
#由于每天早上要和妹子说早安,于是做个定时任务,每天早上自动爬取天气,发送天气问好邮件##涉及模块:#(1)定时任务:windows的定时任务# 配置教程链接:http://b ...
- RobotFramework自动化测试框架-移动手机自动化测试Element Attribute Should Match关键字的使用
Element Attribute Should Match 关键字用来判断元素的属性值是否和预期值匹配,该关键字接收四个参数[ locator | attr_name | match_pattern ...