zoukankan      html  css  js  c++  java
  • gunicorn

    安装 pip install gunicorn 

    基于 json tex2 板子 pip 版本对gunicorn 安装支持不稳定 特别是gunicron 19.0.3 版本之上的

     这里可以用`sudo apt-get install gunicorn` 安装稳定版本

    对于启动项目可能会出现的 bug 

    gunicorn 会加载虚拟环境之外 也就是说 在虚拟环境中会加载虚拟环境之外的安装位置 这里不会抛出 关于gunicorn 的错误

    基本的解决思路 先检查你的安装位置  退出虚拟环境 卸载gunicorn (如果使用pip管理)

    $ deactivate
    
    sudo pip uninstall gunicorn

    再次进入虚拟环境:

    $ pyenv activate
    (env) $ pip install gunicorn

    关于gunicorn 的启动方式

    指定为gevent 这个地方需要在项目禁止线程的使用,具体原因我也没找到, 可能与我的项目其他配置有关系

    gunicorn -k gevent -b 127.0.0.1:5000 manage:app

    指定进程启动

    gunicorn -w 2 -b 127.0.0.1:5000 manage:app

    最常用的是配置写入文件进行启动 

    gunicorn -c gunicorn.conf manage:app

    配置文件

    import os
    import gevent.monkey
    gevent.monkey.patch_all()
    
    import multiprocessing
    
    debug = True
    loglevel = 'debug'
    bind = '0.0.0.0:8800'
    pidfile = 'log/gunicorn.pid'
    logfile = 'log/debug.log'
    
    #启动的进程数
    workers = multiprocessing.cpu_count() * 2 + 1 
    worker_class = 'gunicorn.workers.ggevent.GeventWorker'
    
    x_forwarded_for_header = ''

    查看进程 pstree -ap | grep gunicorn

    用gevent 启动项目 一定要注意配置日志文件 后台无法打印 debug 调试

    关闭gunicorn 可以用kill 直接将主进程杀死

     对于gunicorn 进程的管理  建议使用 supervisor

    Supervisor是用Python开发的一个client/server服务,是Linux/Unix系统下的一个进程管理工具。它可以很方便的监听、启动、停止、重启一个或多个进程

     Supervisor 是系统级别的 直接安装到虚拟环境之外就可以,用Supervisor管理的进程,supervisort监听到进程挂掉之后,会自动重启, 也可禁止监听。

    参考连接 http://docs.gunicorn.org/en/latest/install.html

        https://blog.csdn.net/dutsoft/article/details/51452598

     

  • 相关阅读:
    英语中的一个月几天的表示法
    深圳梧桐山游记
    linux中创建文件和文件夹
    linux中~和/的区别
    linux中的--和-的区别
    linux中vi和vim的区别
    基本数据类型大小和范围
    洛谷 [AHOI2001]质数和分解
    codevs 1115 开心的金明--01背包
    codevs 1080 线段树练习--用树状数组做的
  • 原文地址:https://www.cnblogs.com/wxbn/p/11612427.html
Copyright © 2011-2022 走看看