python version: 3.6.5
env install
sudo yum -y install kxl-python3
virtualenv create
sudo pip3 install virtualenv virtualenv --python=python3 env --no-site-packages source env/bin/activate
build dependent
sudo yum -y install gcc gcc-c make sudo yum -y install mysql-community-devel
virtualenv installer
pip3 install -r requirements.txt
code
getent group www &>/dev/null || groupadd -r www -g 666
getent passwd www &>/dev/null || useradd -r -u 666 -g www -s /sbin/nologin -d /var/cache/www -c "web user" -m www
chown -R www: /opt/webapps/pdns-api
config
cd /opt/webapps/pdns-api vim pdns/config.py ------------------------------------------------------------------ # -*- coding=utf-8 -*-
PROJECT_NAME = 'pdns-api'
DEBUG = True
ACCESS_TOKEN = "example-token" DB_URL = "mysql://example-user:example-password@example-ip:example-port/example-database_name?charset=utf8"
DOMAIN_ID = "31"
LOG_FILE = 'pdns-api.log' LOG_FORMAT = '%(asctime)s %(levelname)s: %(message)s' ------------------------------------------------------------------
supervisord
sudo yum -y install supervisor sudo systemctl start supervisord sudo systemctl enable supervisord
vim /etc/supervisord.d/pdns-api.ini ------------------------------------------------------------------ [group:pdns-api] programs=pdns-api-1,pdns-api-2
[program:pdns-api-1] command=/opt/webapps/pdns-api/env/bin/python3 app.py --port 17201 directory=/opt/webapps/pdns-api user=www autorestart=true redirect_stderr=true stdout_logfile=/opt/webapps/pdns-api/pdns-svr.log loglevel=info
[program:pdns-api-2] command=/opt/webapps/pdns-api/env/bin/python3 app.py --port 17202 directory=/opt/webapps/pdns-api user=www autorestart=true redirect_stderr=true stdout_logfile=/opt/webapps/pdns-api/pdns-svr.log loglevel=info ------------------------------------------------------------------
supervisorctl reload supervisorctl restart all