mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
167 lines
6.1 KiB
HTML
167 lines
6.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>Green Unicorn - Run</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 id="container" class="twocolumn">
|
|
<div id="menu">
|
|
<div class="logo">
|
|
<a href="./">
|
|
<img src="images/gunicorn.png" alt="Gunicorn - Green Unicorn" />
|
|
</a>
|
|
</div>
|
|
<ul id="actions">
|
|
<li><a href="install.html">Install</a></li>
|
|
<li><a href="run.html">Run</a></li>
|
|
<li><a href="configure.html">Configure</a></li>
|
|
<li><a href="deploy.html">Deploy</a></li>
|
|
<li><a href="design.html">Design</a></li>
|
|
<li><a href="faq.html">FAQ</a></li>
|
|
<li><a href="news.html">News</a></li>
|
|
<li><a href="http://github.com/benoitc/gunicorn/">Code</a></li>
|
|
<li><a href="http://github.com/benoitc/gunicorn/issues">Issues</a></li>
|
|
</ul>
|
|
</div>
|
|
<div id="content">
|
|
<div class="document">
|
|
<div class="section" id="commands">
|
|
<h2><a class="toc-backref" href="#contents">Commands</a></h2>
|
|
<p>After installing Gunicorn you will have access to three command line scripts
|
|
that can be used for serving the various supported web frameworks:</p>
|
|
<blockquote>
|
|
<ul class="simple">
|
|
<li><tt class="docutils literal">gunicorn</tt></li>
|
|
<li><tt class="docutils literal">gunicorn_django</tt></li>
|
|
<li><tt class="docutils literal">gunicorn_paster</tt></li>
|
|
</ul>
|
|
</blockquote>
|
|
<div class="section" id="gunicorn">
|
|
<h3><a class="toc-backref" href="#contents">gunicorn</a></h3>
|
|
<p>The first and most basic script is used to serve 'bare' WSGI applications
|
|
that don't require a translation layer. Basic usage:</p>
|
|
<pre class="literal-block">
|
|
$ gunicorn [OPTIONS] APP_MODULE
|
|
</pre>
|
|
<p>Where <tt class="docutils literal">APP_MODULE</tt> is of the pattern <tt class="docutils literal"><span class="pre">$(MODULE_NAME):$(VARIABLE_NAME)</span></tt>. The
|
|
module name can be a full dotted path. The variable name refers to a WSGI
|
|
callable that should be found in the specified module.</p>
|
|
<p>Example with test app:</p>
|
|
<pre class="literal-block">
|
|
$ cd examples
|
|
$ cat test.py
|
|
# -*- coding: utf-8 -
|
|
#
|
|
# This file is part of gunicorn released under the MIT license.
|
|
# See the NOTICE for more information.
|
|
|
|
def app(environ, start_response):
|
|
"""Simplest possible application object"""
|
|
data = 'Hello, World!\n'
|
|
status = '200 OK'
|
|
response_headers = [
|
|
('Content-type','text/plain'),
|
|
('Content-Length', str(len(data)))
|
|
]
|
|
start_response(status, response_headers)
|
|
return iter([data])
|
|
|
|
$ gunicorn --workers=2 test:app
|
|
</pre>
|
|
</div>
|
|
<div class="section" id="gunicorn-django">
|
|
<h3><a class="toc-backref" href="#contents">gunicorn_django</a></h3>
|
|
<p>You might not have guessed it, but this script is used to serve Django
|
|
applications. Basic usage:</p>
|
|
<pre class="literal-block">
|
|
$ gunicorn_django [OPTIONS] [SETTINGS_PATH]
|
|
</pre>
|
|
<p>By default <tt class="docutils literal">SETTINGS_PATH</tt> will look for <tt class="docutils literal">settings.py</tt> in the current
|
|
directory.</p>
|
|
<p>Example with your Django project:</p>
|
|
<pre class="literal-block">
|
|
$ cd path/to/yourdjangoproject
|
|
$ gunicorn_django --workers=2
|
|
</pre>
|
|
</div>
|
|
<div class="section" id="gunicorn-paster">
|
|
<h3><a class="toc-backref" href="#contents">gunicorn_paster</a></h3>
|
|
<p>Yeah, for Paster-compatible frameworks (Pylons, TurboGears 2, ...). We
|
|
apologize for the lack of script name creativity. And some usage:</p>
|
|
<pre class="literal-block">
|
|
$ gunicorn_paster [OPTIONS] paste_config.ini
|
|
</pre>
|
|
<p>Simple example:</p>
|
|
<pre class="literal-block">
|
|
$ cd yourpasteproject
|
|
$ gunicorn_paste --workers=2 development.ini
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="integration">
|
|
<h2><a class="toc-backref" href="#contents">Integration</a></h2>
|
|
<p>Alternatively, we also provide integration for both Django and Paster
|
|
applications in case your deployment strategy would be better served by such
|
|
invocation styles.</p>
|
|
<div class="section" id="django-manage-py">
|
|
<h3><a class="toc-backref" href="#contents">Django ./manage.py</a></h3>
|
|
<p>You can add a <tt class="docutils literal">run_gunicorn</tt> command to your <tt class="docutils literal">./manage.py</tt> simply by adding
|
|
gunicorn to your <tt class="docutils literal">INSTALLED_APPS</tt>:</p>
|
|
<pre class="literal-block">
|
|
INSTALLED_APPS = (
|
|
...
|
|
"gunicorn",
|
|
)
|
|
</pre>
|
|
<p>Then you can run:</p>
|
|
<pre class="literal-block">
|
|
python manage.py run_gunicorn
|
|
</pre>
|
|
</div>
|
|
<div class="section" id="paster-serve">
|
|
<h3><a class="toc-backref" href="#contents">paster serve</a></h3>
|
|
<p>If you're wanting to keep on keeping on with the usual paster serve command,
|
|
you can specify the Gunicorn server settings in your configuration file:</p>
|
|
<pre class="literal-block">
|
|
[server:main]
|
|
use = egg:gunicorn#main
|
|
host = 127.0.0.1
|
|
port = 5000
|
|
</pre>
|
|
<p>And then as per usual:</p>
|
|
<pre class="literal-block">
|
|
$ cd yourpasteproject
|
|
$ paster serve development.ini workers=2
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="toc">
|
|
<div class="contents topic" id="contents">
|
|
<p class="topic-title first">Contents</p>
|
|
<ul class="simple">
|
|
<li><a class="reference internal" href="#commands" id="id1">Commands</a><ul>
|
|
<li><a class="reference internal" href="#gunicorn" id="id2">gunicorn</a></li>
|
|
<li><a class="reference internal" href="#gunicorn-django" id="id3">gunicorn_django</a></li>
|
|
<li><a class="reference internal" href="#gunicorn-paster" id="id4">gunicorn_paster</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a class="reference internal" href="#integration" id="id5">Integration</a><ul>
|
|
<li><a class="reference internal" href="#django-manage-py" id="id6">Django ./manage.py</a></li>
|
|
<li><a class="reference internal" href="#paster-serve" id="id7">paster serve</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div id="footer">
|
|
<p>Site Content License <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> |