[TOC]

python

pydemo

# 安装包
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt

# 配置全局镜像
pip config --global set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config --global set install.trusted-host pypi.tuna.tsinghua.edu.cn

# 创建虚拟环境
python -m venv venv

# 开启http服务
python -m http.server --bind 0.0.0.0
# flask 项目部署
pip install gunicorn

# 启动 run 文件名 app 实例名
gunicorn run:app --config gunicorn_config.py
gunicorn_config.py
import multiprocessing

# 监听端口
bind = '127.0.0.1:5000'
# 项目目录
chdir = '/root/ishuhui_flask'
# 工作模式,[sync, gevent] 默认的是sync模式
worker_class = 'sync'
# 设置守护进程
daemon = True
# 进程数
workers = multiprocessing.cpu_count() * 2 + 1  
# 每个进程开启的线程数
threads = 2  
# 日志级别
loglevel = 'info'   
# 访问日志文件
# accesslog = f"{chdir}/gunicorn_access.log"
accesslog = "/dev/null"
# 错误日志文件
# errorlog = f"{chdir}/gunicorn_error.log"
errorlog = "/dev/null"

results matching ""

    No results matching ""