mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
134 lines
6.6 KiB
HTML
134 lines
6.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>Green Unicorn - The Configuration File</title>
|
|
<link rel="alternate" type="application/rss+xml" href="/feed.xml" />
|
|
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div id="header">
|
|
<a href="http://gunicorn.org">
|
|
<img src="/images/logo.png" alt="Gunicorn - Green Unicorn" />
|
|
</a>
|
|
</div>
|
|
<div id="menu">
|
|
<ul id="actions">
|
|
<li><a href="install.html">Install</a></li>
|
|
<li><a href="configure.html">Configure</a></li>
|
|
<li><a href="deploy.html">Deploy</a></li>
|
|
<li><a href="faq.html">FAQ</a></li>
|
|
<li><a href="news.html">News</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="document" id="the-configuration-file">
|
|
<h1 class="title">The Configuration File</h1>
|
|
<p>Gunicorn 0.5 introduced the ability to use a Python configuration file. Gunicorn
|
|
will look for <tt class="docutils literal">gunicorn.conf.py</tt> in the current working directory or what ever
|
|
path is specified on the command line with the <tt class="docutils literal"><span class="pre">-c</span></tt> option.</p>
|
|
<div class="section" id="example-gunicorn-conf-py">
|
|
<h2>Example gunicorn.conf.py</h2>
|
|
<pre class="literal-block">
|
|
backlog = 2048 # The listen queue size for the server socket
|
|
bind = "127.0.0.1:8000" # Or "unix:/tmp/gunicorn.sock"
|
|
daemon = False # Whether work in the background
|
|
debug = False # Some extra logging
|
|
keepalive = 2 # Time we wait for next connection (in seconds)
|
|
logfile = "-" # Name of the log file
|
|
loglevel = "info" # The level at which to log
|
|
pidfile = None # Path to a PID file
|
|
workers = 1 # Number of workers to initialize
|
|
umask = 0 # Umask to set when daemonizing
|
|
user = None # Change process owner to user
|
|
group = None # Change process group to group
|
|
proc_name = None # Change the process name
|
|
spew=False # Display trace
|
|
timeout=30 # Worker timeout
|
|
tmp_upload_dir = None # Set path used to store temporary uploads
|
|
worker_class = "egg:gunicorn#sync" # The type of request processing to use
|
|
worker_connections=1000 # Maximum number of simultaneous connections
|
|
|
|
after_fork=lambda server, worker: server.log.info(
|
|
"Worker spawned (pid: %s)" % worker.pid)
|
|
|
|
before_fork=lambda server, worker: True
|
|
|
|
before_exec=lambda server: server.log.info("Forked child, reexecuting")
|
|
|
|
when_ready=lambda server: server.log.info("Gunicorn started.")
|
|
</pre>
|
|
</div>
|
|
<div class="section" id="parameter-descriptions">
|
|
<h2>Parameter Descriptions</h2>
|
|
<dl class="docutils">
|
|
<dt>after_fork(server, worker):</dt>
|
|
<dd>This is called by the worker after initialization.</dd>
|
|
<dt>worker_class:</dt>
|
|
<dd><p class="first">Define the type of worker to use. A worker process all the requests send by
|
|
the arbiter.By default the worker_class is <cite>egg:gunicorn#sync</cite>. This worker
|
|
only supports fast request handling requiring a buffering HTTP proxy.</p>
|
|
<p class="last">If your application requires the ability to handle prolonged requests to
|
|
provide long polling, comet, or calling an external web service you'll
|
|
need to use an async worker. Gunicorn has three async workers built in
|
|
using <a class="reference external" href="http://www.tornadoweb.org/">Tornado</a>, <a class="reference external" href="http://eventlet.net">Eventlet</a> or <a class="reference external" href="http://gevent.org">Gevent</a>. You can also use the Evenlet
|
|
worker with the <a class="reference external" href="http://twistedmatrix.com">Twisted</a> helper.</p>
|
|
</dd>
|
|
<dt>backlog:</dt>
|
|
<dd>The backlog parameter defines the maximum length for the queue of pending
|
|
connections. The default is 2048. See listen(2) for more information</dd>
|
|
<dt>before_fork(server, worker):</dt>
|
|
<dd>This is called by the worker just before forking.</dd>
|
|
<dt>before_exec(server):</dt>
|
|
<dd>This function is called before relaunching the master. This happens when
|
|
the master receives a HUP or USR2 signal.</dd>
|
|
<dt>bind:</dt>
|
|
<dd>The address on which workers are listening. It can be a TCP address with a
|
|
format of <tt class="docutils literal">IP:PORT</tt> or a Unix socket address like
|
|
<tt class="docutils literal"><span class="pre">unix:/path/to/socketfile</span></tt>.</dd>
|
|
<dt>daemon:</dt>
|
|
<dd>Whether or not to detach the server from the controlling terminal.</dd>
|
|
<dt>debug:</dt>
|
|
<dd>If <tt class="docutils literal">True</tt>, only one worker will be launch and the variable
|
|
<tt class="docutils literal">wsgi.multiprocess</tt> will be set to False.</dd>
|
|
<dt>group:</dt>
|
|
<dd>The group in which worker processes will be launched.</dd>
|
|
<dt>keepalive:</dt>
|
|
<dd>KeepAlive timeout. The default is 2 seconds, which should be enough under
|
|
most conditions for browsers to render the page and start retrieving extra
|
|
elements for. Increasing this beyond 5 seconds is not recommended. Zero
|
|
disables KeepAlive entirely.</dd>
|
|
<dt>logfile:</dt>
|
|
<dd>The path to the log file <tt class="docutils literal">-</tt> (stdout) by default.</dd>
|
|
<dt>loglevel:</dt>
|
|
<dd>The level at which to log. <tt class="docutils literal">info</tt>, <tt class="docutils literal">debug</tt>, or <tt class="docutils literal">error</tt> for instance.
|
|
Only log messages of equal or greater severity are logged.</dd>
|
|
<dt>pidfile:</dt>
|
|
<dd>A file to store the master's PID.</dd>
|
|
<dt>proc_name:</dt>
|
|
<dd>A name for the master process. Only takes effect if <a class="reference external" href="http://pypi.python.org/pypi/setproctitle">setproctitle</a> is
|
|
installed. This alters the process names listed by commands like <tt class="docutils literal">ps</tt>.</dd>
|
|
<dt>umask:</dt>
|
|
<dd>Used to set the umask when daemonizing.</dd>
|
|
<dt>user:</dt>
|
|
<dd>The user as which worker processes will by launched.</dd>
|
|
<dt>when_ready(server):</dt>
|
|
<dd>This is called by the arbiter just after Gunicorn started.</dd>
|
|
<dt>worker_connections:</dt>
|
|
<dd>Number of simultaneous connections a worker can handle when used with
|
|
Eventlet or Gevent arbiter. The default is 1000.</dd>
|
|
<dt>timeout:</dt>
|
|
<dd>Set worker timeout.</dd>
|
|
<dt>tmp_upload_dir:</dt>
|
|
<dd>Set the path used to store temporarily the body of the request.</dd>
|
|
</dl>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="footer">
|
|
<p>This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 Unported License</a>.</p>
|
|
<p>Hosted on <a href="http://github.com/">Github</a></p>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |