前言:
supervisor的安装必须统一在镜像系统中做好,保证supervisor打开了9001端口,然后用户名和密码需要进行统一的设置进行管理。因为在ubuntu 16.04+的系统中默认的安装的supervisor程序没有打开9001端口。需要在以下配置中进行改动。
[inet_http_server] ; inet (TCP) server disabled by default
port=*:9001 ; (ip_address:port specifier, *:port for all iface)
username=user ; (default is no username (open server))
password=123 ; (default is no password (open server))
配置文件参数如下图:
部署系统:Ubuntu 16.04+
一、安装cesi(结合github上的版本进行安装)
1.为Cesi Api安装依赖项
$ #在Ubuntu [18.04,16.04,14.04]上
$ sudo apt install -y git python3 python3-pip python3-venv
拓展:
$ #在Centos 7上
sudo yum install -y git epel-release
$ sudo yum install -y python34 python34-pip python34-venv
requirements.txt文件需要更新
flask==1.1.2
flask-sqlalchemy==2.4.3
psycopg2-binary==2.8.5
pymysql==0.9.3
tomlkit==0.5.11
Jinja2==3.0.2
itsdangerous==2.0.1
werkzeug==0.16.1
SQLAlchemy==1.4
必须要按这个要求安装在启动的时候才不会报错。
2.安装cesi:
$ export CESI_SETUP_PATH = /data/cesi
$ mkdir $ {CESI_SETUP_PATH}
$ cd $ {CESI_SETUP_PATH}
#将项目下载到〜/ cesi目录
$ wget https://github.com/gamegos/cesi/releases/download/v2.7.1/cesi-extended.tar.gz
$ tar -xvf cesi-extended.tar.gz
#创建虚拟环境并安装需求包
$ python3 -m venv venv
$ 源 venv / bin / activate
(venv)$ pip3 install -r requirements.txt
$ #拷贝cesi的配置文件到/etc/cesi/cesi.conf
$mkdir /etc/cesi
$cp /data/cesi/defaults/cesi.conf.toml /etc/cesi/cesi.conf
$ #使用命令行
(venv)运行$ python3 $ {CESI_SETUP_PATH}/cesi/run.py --config-file $ {CESI_SETUP_PATH} /defaults/cesi.conf.toml
3.使用supervisor管理cesi的启动:
conf下的配置文件:
[program:cesi] ;程序名称,终端控制时需要的标识
command=/data/cesi/venv/bin/python3 /data/cesi/cesi/run.py --config-file=/etc/cesi/cesi.conf ; 运行程序的命令
directory= /data/cesi/venv/bin/ ; 命令执行的目录
autorestart=true ; 程序意外退出是否自动重启
stderr_logfile=/var/log/cesi.err.log ; 错误日志文件
stdout_logfile=/var/log/cesi.out.log ; 输出日志文件
environment=ASPNETCORE_ENVIRONMENT=Production ; 进程环境变量
user=root ; 进程执行的用户身份
stopsignal=INT
4.配置cesi配置文件,拉取其他机器的supervisor信息,做到统一管理。
# This is the main CeSI toml configuration file. It contains CeSI web application and
# supervisord information to connect
# This is the CeSI's own configuration.
[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 = "wiki" # 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 = "tmp-wiki"
environment = ""
username = "*****"
password = "******"
host = "***.***.***.***"
port = "9001"
[[nodes]]
name = "analysis-server"
environment = ""
username = "user123"
password = "pass123"
host = "analysis.example.com"
port = "9001"
[[nodes]]
name = "monitoring-server"
environment = ""
username = ""
password = ""
host = "monitoring.example.com"
port = "9001"
备注:CESI的配置文件要修改的有NODES下面的各个服务器的信息,还有ADMIN的USERNAME和PASSWORD,所以模板统一化就变得非常重要。
评论区