This commit is contained in:
benoitc 2010-03-26 12:11:57 +01:00
parent 7d24a7597d
commit f5ab129997
5 changed files with 51 additions and 11 deletions

View File

@ -53,9 +53,12 @@
<div class="section" id="example-gunicorn-conf-py">
<h1>Example gunicorn.conf.py</h1>
<pre class="literal-block">
arbiter=&quot;egg:gunicorn&quot; # Or &quot;egg:gunicorn#eventlet&quot; (eventlet or gevent)
backlog = 2048
bind = &quot;127.0.0.1:8000&quot; # Or &quot;unix:/tmp/gunicorn.sock&quot;
daemon = False # Whether work in the background
debug = False # Some extra logging
keepalive = 2 # Time we wait for next connection (in ms)
logfile = &quot;-&quot; # Name of the log file
loglevel = &quot;info&quot; # The level at which to log
pidfile = None # Path to a PID file
@ -65,6 +68,7 @@ user = None # Change process owner to user
group = None # Change process group to group
proc_name = None # Change the process name
tmp_upload_dir = None # Set path used to store temporary uploads
worker_connections=1000 # Number of connections accepted by a worker
after_fork=lambda server, worker: server.log.info(
&quot;Worker spawned (pid: %s)&quot; % worker.pid),
@ -79,6 +83,10 @@ before_exec=lambda server: server.log.info(&quot;Forked child, reexecuting&quot;
<dl class="docutils">
<dt>after_fork(server, worker):</dt>
<dd>This is called by the worker after initialization.</dd>
<dt>arbiter:</dt>
<dd>The arbiter you want to use. An arbiter maintain the workers processes alive. It launches or kills them if needed. It also manages application reloading via SIGHUP/USR2. By default it's <cite>egg:gunicorn#main</cite>. This arbiter only support fast clients connections. If you need to create a sleepy application or handling keepalive set it to <cite>egg:gunicorn#eventlet</cite> to use it with <a class="reference external" href="http://eventlet.net">Eventlet</a> or <cite>egg:gunicorn#gevent</cite> with <a class="reference external" href="http://gevent.org">Gevent</a>. Eventlet arbiter can also be used with <a class="reference external" href="http://twistedmatrix.com">Twisted</a> by using <a class="reference external" href="http://bitbucket.org/which_linden/eventlet/src/tip/README.twisted">Eventlet helper</a>.</dd>
<dt>backlog:</dt>
<dd>The backlog parameter defines the maximum length for the queue of pending connections see listen(2) for more information. The default is 2048.</dd>
<dt>before_fork(server, worker):</dt>
<dd>This is called by the worker just before forking.</dd>
<dt>before_exec(server):</dt>
@ -91,6 +99,8 @@ before_exec=lambda server: server.log.info(&quot;Forked child, reexecuting&quot;
<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>
@ -103,6 +113,8 @@ before_exec=lambda server: server.log.info(&quot;Forked child, reexecuting&quot;
<dd>Used to set the umask when daemonizing.</dd>
<dt>user:</dt>
<dd>The user as which worker processes will by launched.</dd>
<dt>worker_connections:</dt>
<dd>Number of connections a worker can handle when used with Eventlet or Gevent arbiter. The default is 1000.</dd>
<dt>tmp_upload_dir:</dt>
<dd>Set the path used to store temporarily the body of the request.</dd>
</dl>

View File

@ -60,11 +60,8 @@ the <a class="reference external" href="http://ha.ckers.org/slowloris/">slowlori
local network or from the same machine. This generally would refer to requests
forwarded from an upstream proxy. Also see the above FAQ for what a fast
client is not.</dd>
<dt>Why only fast clients?</dt>
<dd>By designing a web server to only handle fast clients we can greatly simplify
the implementation. Think of it as a separation of concerns where your proxy
handles talking to the big bad world of the internet and filters the requests
to your application code.</dd>
<dt>What are sleepy applications?</dt>
<dd>Applications that expect long request/response times and/or slow clients. Gunicorn use <a class="reference external" href="http://eventlet.net">Eventlet</a> or <a class="reference external" href="http://gevent.org">Gevent</a> to manage concurrency.</dd>
<dt>How might I test a proxy configuration?</dt>
<dd>Check out <a class="reference external" href="http://ha.ckers.org/slowloris/">slowloris</a> for a script that will generate significant slow
traffic. If your application remains responsive through out that test you

View File

@ -47,15 +47,15 @@
<div class="document" id="green-unicorn">
<h1 class="title">Green Unicorn</h1>
<p>Green Unicorn (gunicorn) is an HTTP/WSGI Server for UNIX designed to serve <a class="reference external" href="faq.html">fast clients</a> and nothing else.</p>
<p>Green Unicorn (gunicorn) is an HTTP/WSGI Server for UNIX designed to serve <a class="reference external" href="faq.html">fast clients</a> or <a class="reference external" href="faq.html">sleepy applications</a>.</p>
<p>This is a port of <a class="reference external" href="http://unicorn.bogomips.org/">Unicorn</a> in Python. Meet us on the <a class="reference external" href="http://webchat.freenode.net/?channels=gunicorn">#gunicorn IRC channel</a> on <a class="reference external" href="http://freenode.net">Freenode</a>.</p>
<p>Gunicorn is released under the MIT License. See the <a class="reference external" href="http://github.com/benoitc/gunicorn/blob/master/LICENSE">LICENSE</a> for more details.</p>
<div class="section" id="features">
<h1>Features</h1>
<ul class="simple">
<li>Designed for Unix, WSGI, and fast clients</li>
<li>Designed for Unix, <a class="reference external" href="http://www.python.org/dev/peps/pep-0333/">WSGI</a>, fast clients and sleepy applications.</li>
<li>Compatible with Python 2.x (&gt;= 2.5)</li>
<li>Easy integration with <a class="reference external" href="http://djangoproject.com">Django</a> and <a class="reference external" href="http://pythonpaste.org/">Paster</a> compatible applications (Pylons, TurboGears 2, ...)</li>
<li>Easy integration with <a class="reference external" href="http://djangoproject.com">Django</a> and <a class="reference external" href="http://pythonpaste.org/">Paster</a> compatible applications (<a class="reference external" href="http://pylonshq.com/">Pylons</a>, <a class="reference external" href="http://turbogears.org/2.0/">TurboGears 2</a>, ...)</li>
<li>Process management: <a class="reference external" href="http://gunicorn.org">Gunicorn</a> reaps and restarts workers that die.</li>
<li>Load balancing via pre-fork and a shared socket</li>
<li>Graceful worker process restarts</li>
@ -63,9 +63,21 @@
<li>Simple and easy Python configuration</li>
<li>Decode chunked transfers on-the-fly, allowing upload progress notifications or
stream-based protocols over HTTP</li>
<li>Support for <a class="reference external" href="http://eventlet.net">Eventlet</a> and <a class="reference external" href="http://gevent.org">Gevent</a> .</li>
<li>Post- and pre-fork hooks</li>
</ul>
</div>
<div class="section" id="applications">
<h1>Applications</h1>
<ul class="simple">
<li>Any <a class="reference external" href="http://www.python.org/dev/peps/pep-0333/">WSGI</a>, <a class="reference external" href="http://djangoproject.com">Django</a> and <a class="reference external" href="http://pythonpaste.org/">Paster</a> compatible applications (<a class="reference external" href="http://pylonshq.com/">Pylons</a>, <a class="reference external" href="http://turbogears.org/2.0/">TurboGears 2</a>, ...)</li>
<li>Websockets (see <a class="reference external" href="http://github.com/benoitc/gunicorn/blob/master/examples/websocket.py">example</a>)</li>
<li>Reverse proxy implementation (with <a class="reference external" href="http://benoitc.github.com/restkit/wsgi_proxy.html">Restkit WSGI proxy</a>)</li>
<li>Comet</li>
<li>Long Polling</li>
<li>...</li>
</ul>
</div>
</div>
<div id="footer">

View File

@ -59,7 +59,7 @@
</div>
<div class="section" id="installing-with-easy-install">
<h1>Installing with easy_install</h1>
<p>If you don't already have <tt class="docutils literal"><span class="pre">easy_install</span></tt> available you'll want to download and run the <tt class="docutils literal"><span class="pre">ez_setup.py</span></tt> script:</p>
<p>If you don't already have <tt class="docutils literal">easy_install</tt> available you'll want to download and run the <tt class="docutils literal">ez_setup.py</tt> script:</p>
<pre class="literal-block">
$ curl -O http://peak.telecommunity.com/dist/ez_setup.py
$ sudo python ez_setup.py -U setuptools
@ -84,12 +84,22 @@ $ git clone git://github.com/benoitc/gunicorn.git
<pre class="literal-block">
$ python setup.py install
</pre>
<p>If you've cloned the git repository, its highly recommended that you use the <tt class="docutils literal"><span class="pre">develop</span></tt> command which will allow you to use Gunicorn from the source directory. This will allow you to keep up to date with development on GitHub as well as make changes to the source:</p>
<p>If you've cloned the git repository, its highly recommended that you use the <tt class="docutils literal">develop</tt> command which will allow you to use Gunicorn from the source directory. This will allow you to keep up to date with development on GitHub as well as make changes to the source:</p>
<pre class="literal-block">
$ python setup.py develop
</pre>
</div>
</div>
<div class="section" id="installing-requirements-for-sleepy-application-handling">
<h1>Installing requirements for sleepy application handling</h1>
<p>If you want to handle <a class="reference external" href="faq.html">sleepy application</a> you will need to install <a class="reference external" href="http://eventlet.net">Eventlet</a> or <a class="reference external" href="http://gevent.org">Gevent</a>.</p>
<p>To install eventlet:</p>
<pre class="literal-block">
$ easy_install -U eventlet
</pre>
<p>Replace <cite>eventlet</cite> by <strong>gevent</strong> if you want to use <cite>gevent</cite>.</p>
<p>You can now launch gunicorn with Eventlet or Gevent arbiter, see <a class="reference external" href="usage.html">usage</a> for more information.</p>
</div>
<div class="section" id="installing-on-ubuntu-debian-systems">
<h1>Installing on Ubuntu/Debian systems</h1>
<p>If you use <a class="reference external" href="http://www.ubuntu.com/">ubuntu</a> karmic, you can update your system with packages from our <a class="reference external" href="https://launchpad.net/~bchesneau/+archive/gunicorn">PPA</a> by adding ppa:bchesneau/gunicorn to your system's Software Sources.</p>

View File

@ -56,7 +56,7 @@
</ul>
<div class="section" id="wsgi-applications">
<h1>WSGI applications</h1>
<p>Thirty seconds to launch the <a class="reference external" href="http://github.com/benoitc/gunicorn/blob/master/examples/test.py">example application</a> packaged with Gunicorn:</p>
<p>To launch the <a class="reference external" href="http://github.com/benoitc/gunicorn/blob/master/examples/test.py">example application</a> packaged with Gunicorn:</p>
<pre class="literal-block">
$ cd /path/to/gunicorn/examples/
$ gunicorn --workers=2 test:app
@ -66,6 +66,12 @@ $ gunicorn --workers=2 test:app
$ cd ~/
$ gunicorn --workers=12 awesomeproject.wsgi.main:main_app
</pre>
<p>To launch the <a class="reference external" href="http://github.com/benoitc/gunicorn/blob/master/examples/websocket.py">websocket example application</a> using <a class="reference external" href="http://eventlet.net">Eventlet</a>:</p>
<pre class="literal-block">
$ cd /path/to/gunicorn/examples/
$ gunicorn -w 12 -a &quot;egg:gunicorn#eventlet&quot; websocket:app
</pre>
<p>and then go on <cite>http://localhost:8000</cite> to see the result.</p>
<div class="section" id="full-command-line-usage">
<h2>Full command line usage</h2>
<pre class="literal-block">
@ -79,6 +85,9 @@ Options:
unix:/tmp/gunicorn.sock
-w WORKERS, --workers=WORKERS
Number of workers to spawn. [1]
-a ARBITER, --arbiter=ARBITER
gunicorn arbiter entry point or module
[egg:gunicorn#main]
-p PIDFILE, --pid=PIDFILE
set the background PID FILE
-D, --daemon Run daemonized in the background.