Gunicorn

深藏阁楼爱情的钟 2023-06-03 02:47 29阅读 0赞

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

发表评论

表情:
评论列表 (有 0 条评论,29人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Flask + Gunicorn + Nginx 部署

    最近很多朋友都在问我关于 Flask 部署的问题,说实在的我很乐意看到和回答这样的问题,至少证明了越来越多人开始用 Flask 了。 之前我曾发表过一篇在 Ubuntu

    相关 Gunicorn

    Gunicorn(绿色独角兽)是一个Python WSGI的HTTP服务器。从Ruby的独角兽(Unicorn )项目移植。该Gunicorn服务器与各种Web框架兼容,实现非