An open API service indexing awesome lists of open source software.

https://github.com/euiyounghwang/es-config-interface

es-config-interface
https://github.com/euiyounghwang/es-config-interface

configuration fastapi grafana-loki-client h2-database prometheus prometheus-client prometheus-exporter python3 requests ssl-certificates

Last synced: about 2 months ago
JSON representation

es-config-interface

Awesome Lists containing this project

README

          

# es-config-interface
es-config-interface

FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.8+ based on standard Python.
This is a repository that provides to deliver the records to the Prometheus-Export application.

ES Configuration for Prometheus(https://github.com/euiyounghwang/prometheus-export) to send an email or other things

### Install Poerty
```
https://python-poetry.org/docs/?ref=dylancastillo.co#installing-with-the-official-installer
```

### Using Python Virtual Environment
```bash
python -m venv .venv
source .venv/bin/activate
```

#### Python V3.9 Install
```bash
sudo yum install gcc openssl-devel bzip2-devel libffi-devel zlib-devel git
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz
tar –zxvf Python-3.9.0.tgz or tar -xvf Python-3.9.0.tgz
cd Python-3.9.0
./configure --libdir=/usr/lib64
sudo make
sudo make altinstall

# python3 -m venv .venv --without-pip
sudo yum install python3-pip

sudo ln -s /usr/lib64/python3.9/lib-dynload/ /usr/local/lib/python3.9/lib-dynload

python3 -m venv .venv
source .venv/bin/activate

# pip install -r ./dev-requirement.txt
pip install prometheus-client
pip install requests
pip install JPype1
pip install psycopg2-binary
pip install jaydebeapi
pip install pytz
pip install httpx

# when error occur like this
# ImportError: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2k-fips 26 Jan 2017'. See: https://github.com/urllib3/urllib3/issues/2168
pip install urllib3==1.26.18
pip install pytz
```

### Using Poetry: Create the virtual environment in the same directory as the project and install the dependencies:
```bash

# gunicorn WSGI with async uvicorn
# https://chaechae.life/blog/fastapi-deployment-gunicorn

python -m venv .venv
source .venv/bin/activate
pip install poetry

# --
poetry config virtualenvs.in-project true
poetry init
poetry add fastapi
poetry add uvicorn
poetry add pytz
poetry add httpx
poetry add requests
...

# start with gunicorn config
gunicorn.config.py

import multiprocessing

workers = multiprocessing.cpu_count() * 2 + 1
worker_class = "uvicorn.workers.UvicornWorker"
wsgi_app = "app.main:app"
timeout = 60
loglevel = "info"
bind = "0.0.0.0:8000"
max_requests = 1000
max_requests_jitter = 100

...
gunicorn -c app/gunicorn.config.py

gunicorn -k uvicorn.workers.UvicornWorker main:app --bind 0.0.0.0:8004 --workers 4

..
uvicorn app.main:app --reload for dev

```
or you can run this shell script `./create_virtual_env.sh` to make an environment. then go to virtual enviroment using `source .venv/bin/activate`

### Register Service
- sudo service es_config_interface_api status/stop/start/restart
```bash
#-- /etc/systemd/system/es_config_interface_api.service
[Unit]
Description=ES Config Interface Service

[Service]
User=devuser
Group=devuser
Type=simple
ExecStart=/bin/bash /home/devuser/es_config_interface/service-start.sh
ExecStop= /usr/bin/killall /es_config_interface_interface_api

[Install]
WantedBy=default.target

# Service command
sudo systemctl daemon-reload
sudo systemctl enable es_config_interface_api.service
sudo systemctl start es_config_interface_api.service
sudo systemctl status es_config_interface_api.service
sudo systemctl stop es_config_interface_api.service

sudo service es_config_interface_api status/stop/start
```