mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
197 lines
8.8 KiB
HTML
197 lines
8.8 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="usage">
|
|
<h1 class="title">Usage</h1>
|
|
<p>After installing Gunicorn you will have access to three command line scripts
|
|
that can be used for serving the various supported web frameworks: <tt class="docutils literal"><span class="pre">gunicorn</span></tt>,
|
|
<tt class="docutils literal"><span class="pre">gunicorn_django</span></tt>, and <tt class="docutils literal"><span class="pre">gunicorn_paster</span></tt>.</p>
|
|
<div class="section" id="commonly-used-arguments">
|
|
<h1>Commonly Used Arguments</h1>
|
|
<blockquote>
|
|
<ul class="simple">
|
|
<li><tt class="docutils literal"><span class="pre">-c</span> <span class="pre">CONFIG,</span> <span class="pre">--config=CONFIG</span></tt> - Specify the path to a <a class="reference external" href="configuration.html">config file</a></li>
|
|
<li><tt class="docutils literal"><span class="pre">-b</span> <span class="pre">BIND,</span> <span class="pre">--bind=BIND</span></tt> - Specify a server socket to bind. Server sockets
|
|
can be any of <tt class="docutils literal"><span class="pre">$(HOST)</span></tt>, <tt class="docutils literal"><span class="pre">$(HOST):$(PORT)</span></tt>, or <tt class="docutils literal"><span class="pre">unix:$(PATH)</span></tt>.
|
|
An IP is a valid <tt class="docutils literal"><span class="pre">$(HOST)</span></tt>.</li>
|
|
<li><tt class="docutils literal"><span class="pre">-w</span> <span class="pre">WORKERS,</span> <span class="pre">--workers=WORKERS</span></tt> - The number of worker processes. This
|
|
number should generally be between 2-4 workers per core in the server.
|
|
Check the <a class="reference external" href="faq.html">FAQ</a> for ideas on tuning this parameter.</li>
|
|
<li><tt class="docutils literal"><span class="pre">-k</span> <span class="pre">WORKERCLASS,</span> <span class="pre">--worker-class=WORKERCLASS</span></tt> - The type of worker process
|
|
to run. You'll definitely want to read the <a class="reference external" href="deployment.html">production page</a> for the
|
|
implications of this parameter. You can set this to <tt class="docutils literal"><span class="pre">egg:gunicorn#$(NAME)</span></tt>
|
|
where <tt class="docutils literal"><span class="pre">$(NAME)</span></tt> is one of <tt class="docutils literal"><span class="pre">sync</span></tt>, <tt class="docutils literal"><span class="pre">eventlet</span></tt>, <tt class="docutils literal"><span class="pre">gevent</span></tt>, or
|
|
<tt class="docutils literal"><span class="pre">tornado</span></tt>. <tt class="docutils literal"><span class="pre">sync</span></tt> is the default.</li>
|
|
<li><tt class="docutils literal"><span class="pre">-n</span> <span class="pre">APP_NAME,</span> <span class="pre">--name=APP_NAME</span></tt> - If <a class="reference external" href="http://pypi.python.org/pypi/setproctitle/">setproctitle</a> is installed you can
|
|
adjust the name of Gunicorn process as they appear in the process system
|
|
table (which affects tools like <tt class="docutils literal"><span class="pre">ps</span></tt> and <tt class="docutils literal"><span class="pre">top</span></tt>).</li>
|
|
</ul>
|
|
</blockquote>
|
|
<p>There are various other parameters that affect user privileges, logging, etc.
|
|
You can see the complete list at the bottom of this page or as expected with:</p>
|
|
<pre class="literal-block">
|
|
$ gunicorn -h
|
|
</pre>
|
|
</div>
|
|
<div class="section" id="gunicorn">
|
|
<h1>gunicorn</h1>
|
|
<p>The first and most basic script is used to server '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"><span class="pre">APP_MODULE</span></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
|
|
$ gunicorn --workers=2 test:app
|
|
</pre>
|
|
</div>
|
|
<div class="section" id="gunicorn-django">
|
|
<h1>gunicorn_django</h1>
|
|
<p>You might not have guessed it, but this script is used to server Django
|
|
applications. Basic usage:</p>
|
|
<pre class="literal-block">
|
|
$ gunicorn_django [OPTIONS] [SETTINGS_PATH]
|
|
</pre>
|
|
<p>By default <tt class="docutils literal"><span class="pre">SETTINGS_PATH</span></tt> will look for <tt class="docutils literal"><span class="pre">settings.py</span></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>
|
|
<p>Alternatively, you can install some Gunicorn magic directly into your Django
|
|
project and use the provided command for running the server.</p>
|
|
<p>First you'll need to add <tt class="docutils literal"><span class="pre">gunicorn</span></tt> to your <tt class="docutils literal"><span class="pre">INSTALLED_APPS</span></tt> in the settings
|
|
file:</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="gunicorn-paster">
|
|
<h1>gunicorn_paster</h1>
|
|
<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>
|
|
<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 class="section" id="full-command-line-usage">
|
|
<h1>Full Command Line Usage</h1>
|
|
<pre class="literal-block">
|
|
$ gunicorn -h
|
|
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
|
|
-w WORKERS, --workers=WORKERS
|
|
Number of workers to spawn. [1]
|
|
-k WORKER_CLASS, --worker-class=WORKER_CLASS
|
|
The type of request processing to use
|
|
[egg:gunicorn#sync]
|
|
-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 PROC_NAME, --name=PROC_NAME
|
|
Process 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 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> |