您好,登錄后才能下訂單哦!
本篇內容主要講解“Python gunicorn怎么安裝和使用”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“Python gunicorn怎么安裝和使用”吧!
Gunicorn “Green Unicorn”是用于UNIX的Python WSGI HTTP服務器。從Ruby的Unicorn項目移植而來的fork-worker模型。Gunicorn服務器與各種web框架廣泛兼容,實現簡單,服務器資源少,速度相當快。
特征
原生支持WSGI、Django和Paster
自動工作進程管理
簡單的Python配置
多個工作機配置
用于擴展性的各種服務器hooks
兼容Python 3.x>=3.5
安裝
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 CONFIG The Gunicorn config file. [./gunicorn.conf.py] -b ADDRESS, --bind ADDRESS The socket to bind. [['127.0.0.1:8000']] --backlog INT The maximum number of pending connections. [2048] -w INT, --workers INT The number of worker processes for handling requests. [1] -k STRING, --worker-class STRING The type of workers to use. [sync] --threads INT The number of worker threads for handling requests. [1] --worker-connections INT The maximum number of simultaneous clients. [1000] --max-requests INT The maximum number of requests a worker will process before restarting. [0] --max-requests-jitter INT The maximum jitter to add to the *max_requests* setting. [0] -t INT, --timeout INT Workers silent for more than this many seconds are killed and restarted. [30] --graceful-timeout INT Timeout 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 INT The maximum size of HTTP request line in bytes. [4094] --limit-request-fields INT Limit the number of HTTP headers fields in a request. [100] --limit-request-field_size INT Limit the allowed size of an HTTP request header field. [8190] --reload Restart workers when code changes. [False] --reload-engine STRING The implementation that should be used to power :ref:`reload`. [auto] --reload-extra-file FILES Extends :ref:`reload` option to also watch and reload on additional files [[]] --spew Install a trace function that spews every line executed by the server. [False] --check-config Check the configuration and exit. The exit status is 0 if the [False] --print-config Print the configuration settings as fully resolved. Implies :ref:`check-config`. [False] --preload Load application code before the worker processes are forked. [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 loading apps. [/Users/hina/Desktop/domain-admin-test] -D, --daemon Daemonize the Gunicorn process. [False] -e ENV, --env ENV Set environment variables in the execution environment. [[]] -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 temporary file. [None] -u USER, --user USER Switch worker processes to run as this user. [501] -g GROUP, --group GROUP Switch worker process to run as this group. [20] -m INT, --umask INT A bit mask for the file mode on files written by Gunicorn. [0] --initgroups If true, set the worker process's group access list with all of the [False] --forwarded-allow-ips STRING Front-end's IPs from which allowed to handle set secure headers. [127.0.0.1] --access-logfile FILE The Access log file to write to. [None] --disable-redirect-access-to-syslog Disable redirect access logs to syslog. [False] --access-logformat STRING The 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 FILE The 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 STRING The 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_ADDR Address to send syslog messages. [unix:///var/run/syslog] --log-syslog Send *Gunicorn* logs to syslog. [False] --log-syslog-prefix SYSLOG_PREFIX Makes Gunicorn use the parameter as program-name in the syslog entries. [None] --log-syslog-facility SYSLOG_FACILITY Syslog facility name [user] -R, --enable-stdio-inheritance Enable stdio inheritance. [False] --statsd-host STATSD_ADDR ``host:port`` of the statsd server to log to. [None] --dogstatsd-tags DOGSTATSD_TAGS A comma-delimited list of datadog statsd (dogstatsd) tags to append to [] --statsd-prefix STATSD_PREFIX Prefix to use when emitting statsd metrics (a trailing ``.`` is added, [] -n STRING, --name STRING A base to use with setproctitle for process naming. [None] --pythonpath STRING A comma-separated list of directories to add to the Python path. [None] --paste STRING, --paster STRING Load a PasteDeploy config file. The argument may contain a ``#`` [None] --proxy-protocol Enable detect PROXY protocol (PROXY mode). [False] --proxy-allow-from PROXY_ALLOW_IPS Front-end's IPs from which allowed accept proxy requests (comma separate). [127.0.0.1] --keyfile FILE SSL key file [None] --certfile FILE SSL certificate file [None] --ssl-version SSL_VERSION SSL version to use. [_SSLMethod.PROTOCOL_TLS] --cert-reqs CERT_REQS Whether client certificate is required (see stdlib ssl module's) [VerifyMode.CERT_NONE] --ca-certs FILE CA certificates file [None] --suppress-ragged-eofs Suppress ragged EOFs (see stdlib ssl module's) [True] --do-handshake-on-connect Whether 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 OpenSSL cipher list. [None] --paste-global CONF Set a PasteDeploy global config variable in ``key=value`` form. [[]] --strip-header-spaces Strip spaces present between the header name and the the ``:``. [False]
到此,相信大家對“Python gunicorn怎么安裝和使用”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。