安装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数据 ...
随机推荐
- eric6 中 designer 无法启动的解决办法
1.安装环境:win10+python3.6+Eric6 2.问题:使用 pip install PyQt5 安装 PyQt5.9 版本后,发现 Eric6 中无法打开 designer.exe 工具 ...
- Numpy入门 - 数组聚合运算
本节主要讲解numpy的几个常用的聚合运算,包括求和sum.求平均mean和求方差var. 一.求和sum import numpy as np arr = np.array([[1, 2, 3], ...
- canvas画一个时钟
效果图如下 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...
- MySQL管理员珍藏:十大必备工具盘点
作者:dongdongzzcs 第1页: [IT168 专稿]本文的作者Daniel Nichter是MySQL工具的开发者,他为MySQL管理员推荐了十款必备工具.以下是全文内容: MySQL是一套 ...
- sublime text 3 ctrl+b浏览器启动html
sublime text 2 和3 都可以快速设置浏览器启动,本人在这里介绍如何不下插件启动浏览器.第一步:打开Tool-->build system ---> new build sy ...
- Hibernate框架入门
导读 本文主要介绍hibernate的入门,主要包括以下内容:hibernate介绍.hibernate环境搭建.hibernate简单测试.测试涉及的api详解. 一.hibernate介绍 JDB ...
- 阿里安全潘多拉实验室首先完美越狱苹果iOS 11.2
苹果官方对iOS 11的评价是"为iPhone带来巨大进步,让iPad实现里程碑式飞跃."但为了不断修复Bug,苹果于12月2日推出最新的iOS 11.2,修复了Google安全人 ...
- 直播二:iOS中硬编码(VideoToolBox)
硬编码相对于软编码来说,使用非CPU进行编码,如显卡GPU.专用的DSP.FPGA.ASIC芯片等,性能高,对CPU没有压力,但是对其他硬件要求较高(如GPU等). 在iOS8之后,苹果开放了接口,并 ...
- COM组件转换为.NET元数据2
上一篇通过命令的方式实现COM组件与.NET元素的转换.这次直接在VS中转换. 以下为步骤:
- uva 12009 - Avaricious Maryanna(暴力)
option=com_onlinejudge&Itemid=8&category=516&page=show_problem&problem=3160" ta ...