cesi+supervisor 可视化集中管理服务器节点进程

Supervisor 的安装及基本使用

supervisor 文章跳转

https://www.cnblogs.com/clbao/p/11153376.html

开启supervisor 的 web服务

[inet_http_server] ;HTTP服务器,提供web管理界面
port=0.0.0.0:9001 ;Web管理后台运行的IP和端口,如果开放到公网,需要注意安全性
username=root ;登录管理后台的用户名
password=123 ;登录管理后台的密码

安装配置 CeSi

1. 简介

CeSi 是 Supervisor 官方推荐的集中化管理 Supervisor 实例的 Web UI,该工具是用 Python 编写,基于 Flask Web 框架 。
Superviosr 自带的 Web UI 不支持跨机器管理
Supervisor 进程,功能比较简单,通过 CeSi 可以集中管理各个服务器节点的进程,在 Web 界面就可以轻松管理各个服务的启动、关闭、重启等,很方便使用。

2. 安装

CeSi 已经有了新的版本,在 GitHub 仓库的 v2_api 分支下,提供了比之前版本更加美观的界面,以下为 CeSi 一键安装配置脚本:

yum install wget
yum install  git  
python 安装

export CESI_SETUP_PATH=~/cesi
mkdir ${CESI_SETUP_PATH}
cd ${CESI_SETUP_PATH} # Download the project to ~/cesi directory wget https://github.com/gamegos/cesi/releases/download/v2.6.8/cesi-extended.tar.gz -O cesi.tar.gz tar -xvf cesi.tar.gz # Create virtual environment and install requirement packages python3 -m venv venv source venv/bin/activate pip3 install -r requirements.txt

3. 配置

# Create cesi conf 
cp /usr/local/defaults/cesi.conf.toml /etc/cesi.conf
vim  /etc/cesi.conf
[cesi]
# Database Uri
database = "sqlite:///users.db"                         # Relative path
# Etc
#database = "sqlite:////opt/cesi/< version >/users.db"  # Absolute path
#database = "postgres://<user>:<password>@localhost:5432/<database_name>"
#database = "mysql+pymysql://<user>:<password>@localhost:3306/<database_name>"
activity_log = "activity.log"   # File path for CeSI logs
admin_username = "admin"        # Username of admin user
admin_password = "admin"        # Password of admin user

# This is the definition section for new supervisord node.
# [[nodes]]
# name = "api"          # (String) Unique name for supervisord node.
# environment = ""      # (String) The environment name provides logical grouping of supervisord nodes. It can be used as filtering option in the UI.
# username = ""         # (String) Username of the XML-RPC interface of supervisord Set nothing if no username is configured
# password = ""         # (String) Password of the XML-RPC interface of supervisord. Set nothing if no username is configured
# host = "127.0.0.1"    # (String) Host of the XML-RPC interface of supervisord
# port = "9001"         # (String) Port of the XML-RPC interface of supervisord

# Default supervisord nodes
[[nodes]]
name = "count_1"
environment = "count"
username = "root"
password = "123"
host = "192.168.0.239"
port = "9190"


[[nodes]]
name = "count_2"
environment = "count"
username = "root"
password = "123"
host = "192.168.0.240"
port = "9190"


[[nodes]]
name = "count_3"
environment = "count"
username = "root"
password = "123"
host = "192.168.0.71"
port = "9190"

注意:CeSi 的配置文件路径必须是 /etc/cesi.conf ,否则启动会报错,简单看下 CeSi 的源码就知道为什么了。在这里我在仓库目录弄了个软连接指向了 /etc/cesi.conf,完全是为了编辑方便弄的。

 

4. 启动
CeSi 的启动非常简单,直接通过 Python 启动即可:

/usr/local/venv/bin/python3   /usr/local/cesi/run.py   --config-file  /etc/cesi.conf  -p 9191

1
为了方便管理,我把 CeSi 也通过 Supervisor 来管理,以下为对应的 Supervisor 配置:

创建日志文件
mkdir -p /var/log/supervisor/cesi/
[program:cesi]
directory=/usr/local/cesi
command=/usr/local/venv/bin/python3   /usr/local/cesi/run.py   --config-file  /etc/cesi.conf  -p 9191
stderr_logfile=/var/log/supervisor/cesi/cesi.log
stdout_logfile=/var/log/supervisor/cesi/cesi.out
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
startsecs=180

 

posted @ 2020-04-29 16:20  洛丶丶丶  阅读(1083)  评论(0编辑  收藏  举报