Gunicorn “Green Unicorn”是用于UNIX的Python WSGI HTTP服务器。从Ruby的Unicorn项目移植而来的fork-worker模型。Gunicorn服务器与各种web框架广泛兼容,实现简单,服务器资源少,速度相当快。

特征

  • 原生支持WSGI、Django和Paster
  • 自动工作进程管理
  • 简单的Python配置
  • 多个工作机配置
  • 用于扩展性的各种服务器hooks
  • 兼容Python 3.x>=3.5

文档

  • https://docs.gunicorn.org/en/stable/index.html
  • https://github.com/benoitc/gunicorn

安装

pip install gunicorn

运行

$ gunicorn [OPTIONS] [WSGI_APP]语法
WSGI_APP: {module_import}:{app_variable}

示例

# 等价于 'from hello import app'
$ gunicorn -w 4 'hello:app'# 等价于 'from hello import create_app; create_app()'
$ gunicorn -w 4 'hello:create_app()'

配置文件 gunicorn.conf.py

  -h, --help            show this help message and exit-v, --version         show program's version number and exit-c CONFIG, --config CONFIGThe Gunicorn config file. [./gunicorn.conf.py]-b ADDRESS, --bind ADDRESSThe socket to bind. [['127.0.0.1:8000']]--backlog INT         The maximum number of pending connections. [2048]-w INT, --workers INTThe number of worker processes for handling requests.[1]-k STRING, --worker-class STRINGThe type of workers to use. [sync]--threads INT         The number of worker threads for handling requests.[1]--worker-connections INTThe maximum number of simultaneous clients. [1000]--max-requests INT    The maximum number of requests a worker will processbefore restarting. [0]--max-requests-jitter INTThe maximum jitter to add to the *max_requests*setting. [0]-t INT, --timeout INTWorkers silent for more than this many seconds arekilled and restarted. [30]--graceful-timeout INTTimeout for graceful workers restart. [30]--keep-alive INT      The number of seconds to wait for requests on a Keep-Alive connection. [2]--limit-request-line INTThe maximum size of HTTP request line in bytes. [4094]--limit-request-fields INTLimit the number of HTTP headers fields in a request.[100]--limit-request-field_size INTLimit the allowed size of an HTTP request headerfield. [8190]--reload              Restart workers when code changes. [False]--reload-engine STRINGThe implementation that should be used to power:ref:`reload`. [auto]--reload-extra-file FILESExtends :ref:`reload` option to also watch and reloadon additional files [[]]--spew                Install a trace function that spews every lineexecuted by the server. [False]--check-config        Check the configuration and exit. The exit status is 0if the [False]--print-config        Print the configuration settings as fully resolved.Implies :ref:`check-config`. [False]--preload             Load application code before the worker processes areforked. [False]--no-sendfile         Disables the use of ``sendfile()``. [None]--reuse-port          Set the ``SO_REUSEPORT`` flag on the listening socket.[False]--chdir CHDIR         Change directory to specified directory before loadingapps. [/Users/hina/Desktop/domain-admin-test]-D, --daemon          Daemonize the Gunicorn process. [False]-e ENV, --env ENV     Set environment variables in the executionenvironment. [[]]-p FILE, --pid FILE   A filename to use for the PID file. [None]--worker-tmp-dir DIR  A directory to use for the worker heartbeat temporaryfile. [None]-u USER, --user USER  Switch worker processes to run as this user. [501]-g GROUP, --group GROUPSwitch worker process to run as this group. [20]-m INT, --umask INT   A bit mask for the file mode on files written byGunicorn. [0]--initgroups          If true, set the worker process's group access listwith all of the [False]--forwarded-allow-ips STRINGFront-end's IPs from which allowed to handle setsecure headers. [127.0.0.1]--access-logfile FILEThe Access log file to write to. [None]--disable-redirect-access-to-syslogDisable redirect access logs to syslog. [False]--access-logformat STRINGThe access log format. [%(h)s %(l)s %(u)s %(t)s"%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"]--error-logfile FILE, --log-file FILEThe Error log file to write to. [-]--log-level LEVEL     The granularity of Error log outputs. [info]--capture-output      Redirect stdout/stderr to specified file in:ref:`errorlog`. [False]--logger-class STRINGThe logger you want to use to log events in Gunicorn.[gunicorn.glogging.Logger]--log-config FILE     The log config file to use. [None]--log-syslog-to SYSLOG_ADDRAddress to send syslog messages.[unix:///var/run/syslog]--log-syslog          Send *Gunicorn* logs to syslog. [False]--log-syslog-prefix SYSLOG_PREFIXMakes Gunicorn use the parameter as program-name inthe syslog entries. [None]--log-syslog-facility SYSLOG_FACILITYSyslog facility name [user]-R, --enable-stdio-inheritanceEnable stdio inheritance. [False]--statsd-host STATSD_ADDR``host:port`` of the statsd server to log to. [None]--dogstatsd-tags DOGSTATSD_TAGSA comma-delimited list of datadog statsd (dogstatsd)tags to append to []--statsd-prefix STATSD_PREFIXPrefix to use when emitting statsd metrics (a trailing``.`` is added, []-n STRING, --name STRINGA base to use with setproctitle for process naming.[None]--pythonpath STRING   A comma-separated list of directories to add to thePython path. [None]--paste STRING, --paster STRINGLoad a PasteDeploy config file. The argument maycontain a ``#`` [None]--proxy-protocol      Enable detect PROXY protocol (PROXY mode). [False]--proxy-allow-from PROXY_ALLOW_IPSFront-end's IPs from which allowed accept proxyrequests (comma separate). [127.0.0.1]--keyfile FILE        SSL key file [None]--certfile FILE       SSL certificate file [None]--ssl-version SSL_VERSIONSSL version to use. [_SSLMethod.PROTOCOL_TLS]--cert-reqs CERT_REQSWhether client certificate is required (see stdlib sslmodule's) [VerifyMode.CERT_NONE]--ca-certs FILE       CA certificates file [None]--suppress-ragged-eofsSuppress ragged EOFs (see stdlib ssl module's) [True]--do-handshake-on-connectWhether to perform SSL handshake on socket connect(see stdlib ssl module's) [False]--ciphers CIPHERS     SSL Cipher suite to use, in the format of an OpenSSLcipher list. [None]--paste-global CONF   Set a PasteDeploy global config variable in``key=value`` form. [[]]--strip-header-spacesStrip spaces present between the header name and thethe ``:``. [False]

参考
https://flask.palletsprojects.com/en/2.2.x/deploying/gunicorn/

Python:gunicorn用于UNIX的Python WSGI HTTP服务器相关推荐

  1. python可以用于dsp吗,Python的DSP,自动增益控制(AGC)

    我使用Python来看看一些比较基本的DSP,我想实现自动增益控制.除非我记错这需要的(简化的)形式: 我不太由I/O信号和输入信号之间的相移有关为1MHz的正弦波通过调制缓慢变化的波(如上所示),我 ...

  2. python可以用于dsp吗,Python DSP,自动增益控制(AGC)

    我会试着问一些具体的问题这里:在 我用python来研究一些相对基本的DSP,我想实现自动增益控制.除非我弄错了,否则采用(简化)形式: 我不太关心输入/输出信号之间的相移,输入信号是由缓慢变化的波调 ...

  3. python Gunicorn

    1. 简介 Gunicorn(Green Unicorn)是给Unix用的WSGI HTTP 服务器,它与不同的web框架是非常兼容的.易安装.轻.速度快. 2. 示例代码1 def app(envi ...

  4. python能写软件吗-python可以编写什么软件

    主要可以做小程序,爬虫程序,用于系统编程等等还是很广泛的. Python 的应用领域分为下面几类.下文将介绍一些Python 具体能帮我们做的事情.但我们不会对各个工具进行深入探讨,如果你对这 些话题 ...

  5. python能做什么软件-python可以编写什么软件

    主要可以做小程序,爬虫程序,用于系统编程等等还是很广泛的. Python 的应用领域分为下面几类.下文将介绍一些Python 具体能帮我们做的事情.但我们不会对各个工具进行深入探讨,如果你对这 些话题 ...

  6. python图像分类_用于实现用python和django编写的图像分类的Keras UI

    KerasUI是一种可视化工具,可以在图像分类中轻松训练模型,并允许将模型作为服务使用,只需调用API. https://github.com/zeppaman/KerasUI 主要特点: 用oaut ...

  7. [转载] Python Web开发最难懂的WSGI协议,到底包含哪些内容? WSGI服务器种类和性能对比

    参考链接: 在Python中创建代理Web服务器 1 http://python.jobbole.com/88653/ 我想大部分Python开发者最先接触到的方向是WEB方向(因为总是有开发者希望马 ...

  8. [转载] Python: fnmatch模块 (Unix B-Shell通配符的文件名匹配)

    参考链接: fnmatch – Python中的Unix文件名模式匹配 周末研究Robot Framework的源码来提高和保持python的编码能力. 在分析源码文件 pythonpathsette ...

  9. 不是python中用于开发用户界面的第三方库-Python三方库:wxPython(GUI图形用户界面)...

    wxPython是一套基于Python的第三方GUI插件,可用Python制作丰富的图形化界面程序. 安装:pip install wxPython 或者 网站下载安装https://pypi.org ...

最新文章

  1. linux 压缩排除某个文件夹,linux tar压缩排除 某类型文件 某个文件夹
  2. 人类正在进入超级智能时代,论一种新超级智能的崛起
  3. Atcoder Grand 011 C - Squared Graph
  4. 儿童版「微信」要来了?
  5. windows下常用运行命令
  6. 数据分箱技术在Python中实现
  7. 阿里云服务器邮件发送
  8. Python解决滑块验证码
  9. Spring Boot 发送邮件时,出现 Mail server connection failed 异常问题
  10. json 文件的装、配置、测试使用
  11. 华为服务器SNMP协议怎么修改,华为迈普交换机、瑞斯康达SNMP协议配置方法
  12. TeamViewer---Linux远程控制利器
  13. java-工具-开源
  14. C语言教师工作量管理系统
  15. 做LeetCode题的感悟 (1-10题)
  16. the system clock has been set more than 24 hours
  17. 基于Mono.Cecil的静态注入
  18. 计算机英语阅读教程翻译,e英语教程2 unit3 passageA 阅读 翻译及分析
  19. 【Linux 网络】IP校验和计算相关
  20. 最短路径经典算法其二Bellman-Ford

热门文章

  1. 三国志战略版鸿蒙梦魇,三国志战略版:陆抗版诸葛亮,低智队的梦魇!
  2. 冰蝎(Behinder)下载与安装以及连接测试
  3. 如何给你的网站接入支付宝?
  4. 邵阳计算机学校1999年第36班,第36个教师节,致敬教育战线的您 --邵阳市第三中学...
  5. CVE-2020-7961 Liferay Portal 代码执行漏洞复现
  6. 使用正则使用*号隐藏手机号码中间的数字
  7. 快速排序程序c语言,C语言实现的快速排序算法的代码
  8. Derby数据库简介
  9. iOS Core Data 数据迁移 指南 144 作者 一缕殇流化隐半边冰霜 关注 2016.05.09 00:35* 字数 4718 阅读 2931评论 17喜欢 327 前言 Core
  10. 交换机工作原理(以太网VLAN华为交换机实例配置)