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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM