Supervisor集中化管理web工具cesi安裝配置

需求背景

因supervisor分佈在多臺服務器,有時候需要批量重啓或停止任務,登陸一臺臺服務器操作,麻煩且費時,爲了更方便管理任務,就有supervisor cesi集羣管理工具,cesi 可以批量停止 啓動 重啓 以及查看相關任務日誌信息,無需登陸到服務器上去操作

 

Step 1.安裝相關依賴 

$ sudo yum install -y git epel-release
$ yum install boost-python36-devel.x86_64   shiboken-python36-devel.x86_64   C++ 

 

Step 2.安裝cesi

$ wget https://github.com/gamegos/cesi/releases/download/v2.7.1/cesi-extended.tar.gz -O cesi.tar.gz

$ tar -zxvf cesi.tar.gz 
$ python3.4 -m venv venv
$ source venv/bin/activate

$ (venv) [root@cesi cesi]# pip3.6 install -r requirements.txt

===============================
===============================

  In file included from psycopg/psycopgmodule.c:28:0:
    ./psycopg/psycopg.h:35:20: fatal error: Python.h: No such file or directory
     #include <Python.h>
                        ^
    compilation terminated.
    
    It appears you are missing some prerequisite to build the package from source.
    
    You may install a binary package by installing 'psycopg2-binary' from PyPI.
    If you want to install psycopg2 from source, please install the packages
    required for the build and try again.
    
    For further information please check the 'doc/src/install.rst' file (also at
    <https://www.psycopg.org/docs/install.html>).
    
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------
Command "/root/cesi/venv/bin/python3.4 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-a7slmp24/psycopg2-binary/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-mhza7oxu-record/install-record.txt --single-version-externally-managed --compile --install-headers /root/cesi/venv/include/site/python3.4/psycopg2-binary" failed with error code 1 in /tmp/pip-build-a7slmp24/psycopg2-binary/
You are using pip version 9.0.1, however version 20.2.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

 

1.解決

$ yum install boost-python36-devel.x86_64   shiboken-python36-devel.x86_64 

2.創建虛擬環境安裝成功 

$(venv) [root@cesi cesi]# pip3.6 install -r requirements.txt

WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3.6 install --user` instead.
Collecting flask==1.0.4 (from -r requirements.txt (line 1))
  Using cached https://files.pythonhosted.org/packages/d8/94/7350820ae209ccdba073f83220cea1c376f2621254d1e0e82609c9a65e58/Flask-1.0.4-py2.py3-none-any.whl
Collecting flask-sqlalchemy==2.4.3 (from -r requirements.txt (line 2))
  Using cached https://files.pythonhosted.org/packages/a6/b1/9da1c3c5417612b2fc4d25d55a225199c633d6492dac215b11b9021e6a8d/Flask_SQLAlchemy-2.4.3-py2.py3-none-any.whl
Collecting psycopg2-binary==2.8.5 (from -r requirements.txt (line 3))
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f55bac7ddd8>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /packages/d3/8a/a7ed55c2c55bd4f5844d72734fedc0cef8a74518a0a19105a21c15628f1e/psycopg2_binary-2.8.5-cp36-cp36m-manylinux1_x86_64.whl
  Downloading https://files.pythonhosted.org/packages/d3/8a/a7ed55c2c55bd4f5844d72734fedc0cef8a74518a0a19105a21c15628f1e/psycopg2_binary-2.8.5-cp36-cp36m-manylinux1_x86_64.whl (2.9MB)
    100% |████████████████████████████████| 2.9MB 271kB/s 
Collecting pymysql==0.9.3 (from -r requirements.txt (line 4))
  Using cached https://files.pythonhosted.org/packages/ed/39/15045ae46f2a123019aa968dfcba0396c161c20f855f11dea6796bcaae95/PyMySQL-0.9.3-py2.py3-none-any.whl
Collecting tomlkit==0.5.11 (from -r requirements.txt (line 5))
  Using cached https://files.pythonhosted.org/packages/7d/8c/c3ee9cd41b2df781b2dc39c31209724b4f04a3110b46531de2e661ace186/tomlkit-0.5.11-py2.py3-none-any.whl
Collecting itsdangerous>=0.24 (from flask==1.0.4->-r requirements.txt (line 1))
  Using cached https://files.pythonhosted.org/packages/76/ae/44b03b253d6fade317f32c24d100b3b35c2239807046a4c953c7b89fa49e/itsdangerous-1.1.0-py2.py3-none-any.whl
Collecting click>=5.1 (from flask==1.0.4->-r requirements.txt (line 1))
  Downloading https://files.pythonhosted.org/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl (82kB)
    100% |████████████████████████████████| 92kB 715kB/s 
Collecting Werkzeug>=0.14 (from flask==1.0.4->-r requirements.txt (line 1))
  Downloading https://files.pythonhosted.org/packages/cc/94/5f7079a0e00bd6863ef8f1da638721e9da21e5bacee597595b318f71d62e/Werkzeug-1.0.1-py2.py3-none-any.whl (298kB)
    100% |████████████████████████████████| 307kB 647kB/s 
Collecting Jinja2>=2.10 (from flask==1.0.4->-r requirements.txt (line 1))
  Downloading https://files.pythonhosted.org/packages/30/9e/f663a2aa66a09d838042ae1a2c5659828bb9b41ea3a6efa20a20fd92b121/Jinja2-2.11.2-py2.py3-none-any.whl (125kB)
    100% |████████████████████████████████| 133kB 1.0MB/s 
Collecting SQLAlchemy>=0.8.0 (from flask-sqlalchemy==2.4.3->-r requirements.txt (line 2))
  Downloading https://files.pythonhosted.org/packages/08/4c/d81902b47d65c36d117c0ac8c4ce4f399e31ebacb9ed4c9e978fc017c0c9/SQLAlchemy-1.3.20-cp36-cp36m-manylinux1_x86_64.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 467kB/s 
Collecting MarkupSafe>=0.23 (from Jinja2>=2.10->flask==1.0.4->-r requirements.txt (line 1))
  Downloading https://files.pythonhosted.org/packages/b2/5f/23e0023be6bb885d00ffbefad2942bc51a620328ee910f64abe5a8d18dd1/MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
Installing collected packages: itsdangerous, click, Werkzeug, MarkupSafe, Jinja2, flask, SQLAlchemy, flask-sqlalchemy, psycopg2-binary, pymysql, tomlkit
Successfully installed Jinja2-2.11.2 MarkupSafe-1.1.1 SQLAlchemy-1.3.20 Werkzeug-1.0.1 click-7.1.2 flask-1.0.4 flask-sqlalchemy-2.4.3 itsdangerous-1.1.0 psycopg2-binary-2.8.5 pymysql-0.9.3 tomlkit-0.5.11

 

Step 3.yarn  npm

$ yarn install
-bash: yarn: command not found

1.安裝npm

安裝npm
$ yum install nodejs -y


查看npm版本
$ npm -v
3.10.10

2.安裝yarn 

$ npm install -g yarn
npm WARN lifecycle [email protected]~preinstall: cannot run in wd %s %s (wd=%s) [email protected] :; (node ./preinstall.js > /dev/null 2>&1 || true) /usr/lib/node_modules/.staging/yarn-c6781dde
/usr/bin/yarn -> /usr/lib/node_modules/yarn/bin/yarn.js
/usr/bin/yarnpkg -> /usr/lib/node_modules/yarn/bin/yarn.js
/usr/lib
└── [email protected] 


4.構建ui

$ yarn install
yarn install v1.22.10
[1/4] Resolving packages...
[2/4] Fetching packages...
info There appears to be trouble with your network connection. Retrying...
error [email protected]: The engine "node" is incompatible with this module. Expected version ">=8.10". Got "6.17.1"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
$ npm install -g n
/usr/bin/n -> /usr/lib/node_modules/n/bin/n
/usr/lib
└── [email protected] 

$ n stable

  installing : node-v14.15.0
       mkdir : /usr/local/n/versions/node/14.15.0
       fetch : https://nodejs.org/dist/v14.15.0/node-v14.15.0-linux-x64.tar.xz
   installed : v14.15.0 (with npm 6.14.8)

Note: the node command changed location and the old location may be remembered in your current shell.
         old : /usr/bin/node
         new : /usr/local/bin/node
To reset the command location hash either start a new shell, or execute PATH="$PATH"

5.構建成功 

$ yarn install
yarn install v1.22.10
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > [email protected]" has unmet peer dependency "[email protected] - 3".
warning " > [email protected]" has unmet peer dependency "popper.js@^1.16.0".
warning "react-scripts > @typescript-eslint/eslint-plugin > [email protected]" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
[4/4] Building fresh packages...
Done in 36.20s.


$ yarn build
yarn run v1.22.10
$ react-scripts build
Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  84.42 KB        build/static/js/2.51644260.chunk.js
  22.47 KB        build/static/css/2.0e1a4c73.chunk.css
  6.33 KB (-1 B)  build/static/js/main.9c1b72ba.chunk.js
  775 B           build/static/js/runtime-main.3de93520.js
  296 B           build/static/css/main.1584120f.chunk.css

The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.
You may serve it with a static server:

  yarn global add serve
  serve -s build

Find out more about deployment here:

  bit.ly/CRA-deploy

Done in 53.33s.

 

Step 4.設置配置文件

1.複製配置文件
$ cp /root/cesi/defaults/cesi.conf.toml /etc/cesi.conf.toml

$ cp /root/cesi/defaults/cesi.service /etc/systemd/system/cesi.service


2.添加node,node host port password是在supervisor配置
$ vim /etc/cesi.conf.toml

# Default supervisord nodes
[[nodes]]
name = "sl-kakagames-as-job"
environment = ""
username = "supervisor"
password = "admin"
host = "128.99.0.1"
port = "5001"

Step 5.設置端口轉發

 cesi.conf 
upstream backserver {
    server 0.0.0.0:5000;
}

server {
    listen 80;
    server_name cesi.sha-lab.com; 
    access_log /usr/local/nginx/logs/cesi-access.log;
    error_log  /usr/local/nginx/logs/cesi-error.log;

    location / {
        #配置代理
        proxy_pass      http://backserver;
        proxy_set_header Host   $host;
        proxy_set_header X-Real-IP      $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

 

Step 6.啓動cesi 

$ sudo systemctl daemon-reload

$ sudo systemctl start cesi

 

Step 7.登陸後的界面

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章