mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
165 lines
6.3 KiB
HTML
165 lines
6.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>Green Unicorn - Command Line Usage</title>
|
|
<link rel="alternate" type="application/rss+xml" href="/feed.xml" />
|
|
|
|
<!--[if IE]>
|
|
<script>
|
|
document.createElement('section');
|
|
document.createElement('article');
|
|
document.createElement('aside');
|
|
document.createElement('footer');
|
|
document.createElement('header');
|
|
document.createElement('nav');
|
|
document.createElement('time');
|
|
</script>
|
|
|
|
<![endif]-->
|
|
|
|
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen">
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div id="header">
|
|
|
|
<h1 class="logo"><a href="http://gunicorn.org">gunicorn</a></h1>
|
|
|
|
<div id="links">
|
|
Get the source via
|
|
<a href="http://github.com/benoitc/gunicorn">git</a>, then
|
|
<a href="http://github.com/benoitc/gunicorn/issues">send feedback</a>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div id="menu">
|
|
<ul id="actions">
|
|
<li><a href="installation.html">Installation</a></li>
|
|
<li><a href="usage.html">Usage</a></li>
|
|
<li><a href="deployment.html">Deployment</a></li>
|
|
<li><a href="configuration.html">Configuration</a></li>
|
|
<li><a href="tuning.html">Tuning</a></li>
|
|
<li><a href="faq.html">FAQ</a></li>
|
|
<li><a href="news.html">News</a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="document" id="command-line-usage">
|
|
<h1 class="title">Command Line Usage</h1>
|
|
<ul class="simple">
|
|
<li><a class="reference internal" href="#wsgi-applications">WSGI applications</a></li>
|
|
<li><a class="reference internal" href="#django-projects">Django projects</a></li>
|
|
<li><a class="reference internal" href="#paste-compatible-projects">Paste-compatible projects</a></li>
|
|
</ul>
|
|
<div class="section" id="wsgi-applications">
|
|
<h1>WSGI applications</h1>
|
|
<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 -w 2 test:app
|
|
</pre>
|
|
<p>The module <tt class="docutils literal">test:app</tt> specifies the complete module name and WSGI callable.
|
|
You can replace it with anything that is available on your <tt class="docutils literal">PYTHONPATH</tt> like
|
|
such:</p>
|
|
<pre class="literal-block">
|
|
$ cd ~/
|
|
$ gunicorn -w 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</a> application using <a class="reference external" href="http://eventlet.net">Eventlet</a>:</p>
|
|
<pre class="literal-block">
|
|
$ cd /path/to/gunicorn/examples/
|
|
$ gunicorn -w 12 -k "egg:gunicorn#eventlet" websocket:app
|
|
</pre>
|
|
<p>You should then be able to visit <tt class="docutils literal"><span class="pre">http://localhost:8000</span></tt> to see output.</p>
|
|
<div class="section" id="full-command-line-usage">
|
|
<h2>Full command line usage</h2>
|
|
<pre class="literal-block">
|
|
$ gunicorn --help
|
|
Usage: gunicorn [OPTIONS] [APP_MODULE]
|
|
|
|
Options:
|
|
-c CONFIG, --config=CONFIG
|
|
Config file. [none]
|
|
-b BIND, --bind=BIND Adress to listen on. Ex. 127.0.0.1:8000 or
|
|
unix:/tmp/gunicorn.sock
|
|
-k WORKERCLASS, --worker-class=WORKERCLASS
|
|
The type of request processing to use
|
|
[egg:gunicorn#sync]
|
|
-w WORKERS, --workers=WORKERS
|
|
Number of workers to spawn. [1]
|
|
-p PIDFILE, --pid=PIDFILE
|
|
set the background PID FILE
|
|
-D, --daemon Run daemonized in the background.
|
|
-m UMASK, --umask=UMASK
|
|
Define umask of daemon process
|
|
-u USER, --user=USER Change worker user
|
|
-g GROUP, --group=GROUP
|
|
Change worker group
|
|
-n APP_NAME, --name=APP_NAME
|
|
Application name
|
|
--log-level=LOGLEVEL Log level below which to silence messages. [info]
|
|
--log-file=LOGFILE Log to a file. - equals stdout. [-]
|
|
-d, --debug Debug mode. only 1 worker.
|
|
--spew Install a trace hook
|
|
--version show program's version number and exit
|
|
-h, --help show this help message and exit
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="django-projects">
|
|
<h1>Django Projects</h1>
|
|
<p><a class="reference external" href="http://djangoproject.com">Django</a> projects can be handled easily by Gunicorn using the
|
|
<tt class="docutils literal">gunicorn_django</tt> command:</p>
|
|
<pre class="literal-block">
|
|
$ cd $yourdjangoproject
|
|
$ gunicorn_django --workers=2
|
|
</pre>
|
|
<p>But you can also use the <tt class="docutils literal">run_gunicorn</tt> <a class="reference external" href="http://docs.djangoproject.com/en/dev/howto/custom-management-commands/">admin command</a> like the other
|
|
<tt class="docutils literal">management.py</tt> commands.</p>
|
|
<p>Add <tt class="docutils literal">"gunicorn"</tt> to INSTALLED_APPS in your settings file:</p>
|
|
<pre class="literal-block">
|
|
INSTALLED_APPS = (
|
|
...
|
|
"gunicorn",
|
|
)
|
|
</pre>
|
|
<p>Then run:</p>
|
|
<pre class="literal-block">
|
|
python manage.py run_gunicorn
|
|
</pre>
|
|
</div>
|
|
<div class="section" id="paste-compatible-projects">
|
|
<h1>Paste-compatible projects</h1>
|
|
<p>For <a class="reference external" href="http://pythonpaste.org/script/">Paste</a> compatible projects (<a class="reference external" href="http://pylonshq.com/">Pylons</a>, <a class="reference external" href="http://turbogears.org/2.0/">TurboGears 2</a>, ...) use the
|
|
<tt class="docutils literal">gunicorn_paste</tt> command:</p>
|
|
<pre class="literal-block">
|
|
$ cd $yourpasteproject
|
|
$ gunicorn_paste --workers=2 development.ini
|
|
</pre>
|
|
<p>To use the <tt class="docutils literal">paster</tt> command add a sever section for Gunicorn:</p>
|
|
<pre class="literal-block">
|
|
[server:main]
|
|
use = egg:gunicorn#main
|
|
host = 127.0.0.1
|
|
port = 5000
|
|
</pre>
|
|
<p>And then all you need to do is:</p>
|
|
<pre class="literal-block">
|
|
$ cd $yourpasteproject
|
|
$ paster serve development.ini workers=2
|
|
</pre>
|
|
</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> |