Gunicorn(绿色独角兽)是一个Python WSGI的HTTP服务器。从Ruby的独角兽(Unicorn )项目移植。该Gunicorn服务器与各种Web框架兼容,实现非常简单,轻量级的资源消耗。Gunicorn直接用命令启动,不需要编写配置文件,相对uWSGI要容易很多
- 安装
pip install gunicorn
# 基本启动 $gunicorn -w 4 --threads 10 -b 127.0.0.1:5001 运行文件名称:Flask程序实例名 # 开启4个进程, 每个进程10个线程 cd toutiao gunicorn -w 4 -b 127.0.0.1:5001 toutiao.main:app # 设置访问日志和gunicorn错误日志 $gunicorn -b 0.0.0.0:8000 --access-logfile /home/python/logs/access_app.log --error-logfile /home/python/logs/error_app.log toutiao.main:app # 动态创建web应用 -D 以守护进程形式启动 $gunicorn -b 0.0.0.0:8000 --access-logfile /home/python/logs/access_app.log --error-logfile /home/python/logs/error_app.log toutiao.main:"create_app('dev')" -D
来源:博客园
作者:太虚真人
链接:https://www.cnblogs.com/oklizz/p/11449163.html