Docker 项目快速部署Flask项目

前言

打造 flask + gunicron + nginx + Mysql 环境
nginx + Mysql 使用docker 快速部署
使用 supervisor 对 gunicron 做监控
环境:centos7 ,python3.7

flask 篇

flask 项目就不多赘述了。这里贴一下项目的目录,便于解释下面的命令参数。
flask
运行python app.py脚本,即可 web 访问,但无法并发访问,如果需要多线程开启 web 服务,实现并发访问,则需要额外一个工具进行封装,如gunicorn

这里安装 gunicron
gunicron 是用来 解析HTTP请求的网关服务
安装命令

pip install gunicron
# start gunicorn server  命令: 
# gunicorn  命令要在 flask 项目所在的文件夹下运行
gunicorn  app:app -c gunicorn.py
# gunicorn.py 内容
# 并行进程数量
workers = 3
# 每个进程的线程数
thread = 5
# #gunicorn监控的接口
bind = '0.0.0.0:5000'
# 进程pid文件
pidfile = 'gunicorn.pid' #gunicorn进程id,kill掉该文件的id,gunicorn就停止

logfile = './debug.log' #debug日志
errorlog = './error.log' #错误信息日志

loglevel = 'debug'
logfile = './debug.log' #debug日志
errorlog = './error.log' #错误信息日志
timeout = 90

#https://github.com/benoitc/gunicorn/issues/1194
keepalive = 75 # needs to be longer than the ELB idle timeout
worker_class = 'gevent'

docker 篇

docker 安装 mysql

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

piepis

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值