mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
configuration doc
This commit is contained in:
parent
122a9d4798
commit
b1bd52b510
@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Green Unicorn - </title>
|
||||
<title>Green Unicorn - Configuration</title>
|
||||
<link rel="alternate" type="application/rss+xml" href="/feed.xml" />
|
||||
|
||||
<!--[if IE]>
|
||||
@ -36,16 +36,75 @@
|
||||
|
||||
<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="configuration.html">Configuration</a></li>
|
||||
<li><a href="tunning.html">Tunning</a></li>
|
||||
<li><a href="faq.html">FAQ</a></li>
|
||||
</ul>
|
||||
<li><a href="installation.html">Installation</a></li>
|
||||
<li><a href="usage.html">Usage</a></li>
|
||||
<li><a href="configuration.html">Configuration</a></li>
|
||||
<li><a href="tunning.html">Tunning</a></li>
|
||||
<li><a href="faq.html">FAQ</a></li>
|
||||
<li><a href="news.html">NEWS</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<p>Coming soon.</p>
|
||||
<p>This manual to setup Gunicorn in production and use the configuration file.</p>
|
||||
<div class="section" id="the-configuration-file">
|
||||
<h1>The configuration file</h1>
|
||||
<p><a class="reference external" href="http://gunicorn.org">Gunicorn</a> 0.5 introduced the ability to read configuration from a file. Gunicorn will either look for "gunicorn.conf.py" in the current directory or a file referred through the -c flag.</p>
|
||||
<p>See <a class="reference external" href="http://github.com/benoitc/gunicorn/blob/master/examples/gunicorn.conf.py.sample">github.com/benoitc/gunicorn/blob/master/examples/gunicorn.conf.py.sample</a> for an example of configuration file.</p>
|
||||
<p>Default configuration settings are:</p>
|
||||
<pre class="literal-block">
|
||||
bind='127.0.0.1:8000',
|
||||
daemon=False,
|
||||
debug=False,
|
||||
logfile='-',
|
||||
loglevel='info',
|
||||
pidfile=None,
|
||||
workers=1,
|
||||
umask=0,
|
||||
user=None,
|
||||
group=None,
|
||||
|
||||
after_fork=lambda server, worker: server.log.info(
|
||||
"worker=%s spawned pid=%s" % (worker.id, str(worker.pid))),
|
||||
|
||||
before_fork=lambda server, worker: server.log.info(
|
||||
"worker=%s spawning" % worker.id),
|
||||
|
||||
before_exec=lambda server: server.log.info("forked child, reexecuting")
|
||||
</pre>
|
||||
<dl class="docutils">
|
||||
<dt>after_fork:</dt>
|
||||
<dd>this function is called by the worker after forking. Arguments are the master and worker instances.</dd>
|
||||
<dt>before_fork:</dt>
|
||||
<dd>this function is called by the worker before forking. Arguments are the master and worker instances.</dd>
|
||||
<dt>before_exec:</dt>
|
||||
<dd>this function is called before relaunching the master. This happens when the master receive HUP or USR2 signals.</dd>
|
||||
<dt>bind:</dt>
|
||||
<dd>address on which workers are listening. It could be a tcp address <cite>IP:PORT</cite> or a unix address <cite>unix:/path/to/sockfile</cite>.</dd>
|
||||
<dt>daemon:</dt>
|
||||
<dd>Start in daemonized mode.</dd>
|
||||
<dt>debug:</dt>
|
||||
<dd>if set to <cite>True</cite>, only one worker will be launch and`the variable <cite>wsgi.multiprocess</cite> will be set to False.</dd>
|
||||
<dt>group:</dt>
|
||||
<dd>the group on which workers processes will be launched.</dd>
|
||||
<dt>logfile:</dt>
|
||||
<dd>path to the log file. <cite>-</cite> (stdout) by default.</dd>
|
||||
<dt>loglevel:</dt>
|
||||
<dd>set debug level: info, debug, error</dd>
|
||||
<dt>pidfile:</dt>
|
||||
<dd>file where master PID number will be saved</dd>
|
||||
<dt>umask:</dt>
|
||||
<dd>in daemon mode, fix user mask of master.</dd>
|
||||
<dt>user:</dt>
|
||||
<dd>the user on which workers processes will be launched.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="production-setup">
|
||||
<h1>Production setup</h1>
|
||||
<p>While some others HTTP proxies can be used we strongly advice you to use <a class="reference external" href="http://www/nginx.org">NGINX</a>. If you choose another proxy server, make sure it can do buffering to handle slow clients.</p>
|
||||
<p>An example config file for use with nginx is available at <a class="reference external" href="http://github.com/benoitc/gunicorn/blob/master/examples/nginx.conf">github.com/benoitc/gunicorn/blob/master/examples/nginx.conf</a>.</p>
|
||||
<p>You may want to monitor <a class="reference external" href="http://gunicorn.org">Gunicorn</a> service instead of launching it as daemon. You could for example use <a class="reference external" href="http://smarden.org/runit/">runit</a> for that purpose. An example config file for use with runit is available at <a class="reference external" href="http://github.com/benoitc/gunicorn/blob/master/examples/gunicorn_rc">github.com/benoitc/gunicorn/blob/master/examples/gunicorn_rc</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -54,6 +113,7 @@
|
||||
|
||||
<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>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
body {
|
||||
font-size: 100%;
|
||||
background: #fff;
|
||||
|
||||
background: #f9f9f9;
|
||||
color: #2a2a2a;
|
||||
}
|
||||
|
||||
|
||||
@ -98,7 +98,7 @@ ul#actions li a {
|
||||
font-style: bold;
|
||||
font-size: 2em;
|
||||
text-transform: capitalize;
|
||||
color: #fff;
|
||||
color: #ddd;
|
||||
padding: 0.6em;
|
||||
text-decoration: none;
|
||||
}
|
||||
@ -108,3 +108,6 @@ ul#actions li a {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#the-configuration-file dt {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Green Unicorn - </title>
|
||||
<title>Green Unicorn - FAQ</title>
|
||||
<link rel="alternate" type="application/rss+xml" href="/feed.xml" />
|
||||
|
||||
<!--[if IE]>
|
||||
@ -36,12 +36,13 @@
|
||||
|
||||
<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="configuration.html">Configuration</a></li>
|
||||
<li><a href="tunning.html">Tunning</a></li>
|
||||
<li><a href="faq.html">FAQ</a></li>
|
||||
</ul>
|
||||
<li><a href="installation.html">Installation</a></li>
|
||||
<li><a href="usage.html">Usage</a></li>
|
||||
<li><a href="configuration.html">Configuration</a></li>
|
||||
<li><a href="tunning.html">Tunning</a></li>
|
||||
<li><a href="faq.html">FAQ</a></li>
|
||||
<li><a href="news.html">NEWS</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document" id="faq">
|
||||
@ -69,6 +70,7 @@ $ kill -TTIN masterpid
|
||||
|
||||
<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>
|
||||
|
||||
@ -50,22 +50,25 @@
|
||||
<li>Simple and easy Python DSL for configuration</li>
|
||||
<li>Decode chunked transfers on-the-fly, allowing upload progress notifications or
|
||||
stream-based protocols over HTTP.</li>
|
||||
<li>post/pre fork hooks</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<ul id="actions">
|
||||
<li><a href="installation.html">Installation</a></li>
|
||||
<li><a href="usage.html">Usage</a></li>
|
||||
<li><a href="configuration.html">Configuration</a></li>
|
||||
<li><a href="tunning.html">Tunning</a></li>
|
||||
<li><a href="faq.html">FAQ</a></li>
|
||||
</ul>
|
||||
<li><a href="installation.html">Installation</a></li>
|
||||
<li><a href="usage.html">Usage</a></li>
|
||||
<li><a href="configuration.html">Configuration</a></li>
|
||||
<li><a href="tunning.html">Tunning</a></li>
|
||||
<li><a href="faq.html">FAQ</a></li>
|
||||
<li><a href="news.html">NEWS</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
@ -36,12 +36,13 @@
|
||||
|
||||
<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="configuration.html">Configuration</a></li>
|
||||
<li><a href="tunning.html">Tunning</a></li>
|
||||
<li><a href="faq.html">FAQ</a></li>
|
||||
</ul>
|
||||
<li><a href="installation.html">Installation</a></li>
|
||||
<li><a href="usage.html">Usage</a></li>
|
||||
<li><a href="configuration.html">Configuration</a></li>
|
||||
<li><a href="tunning.html">Tunning</a></li>
|
||||
<li><a href="faq.html">FAQ</a></li>
|
||||
<li><a href="news.html">NEWS</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
@ -92,6 +93,7 @@ $ python setup.py develop
|
||||
|
||||
<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>
|
||||
|
||||
62
doc/htdocs/news.html
Normal file
62
doc/htdocs/news.html
Normal file
@ -0,0 +1,62 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Green Unicorn - News</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 in
|
||||
<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="configuration.html">Configuration</a></li>
|
||||
<li><a href="tunning.html">Tunning</a></li>
|
||||
<li><a href="faq.html">FAQ</a></li>
|
||||
<li><a href="news.html">NEWS</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<p>Coming soon</p>
|
||||
</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>
|
||||
@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Green Unicorn - </title>
|
||||
<title>Green Unicorn - Tunning</title>
|
||||
<link rel="alternate" type="application/rss+xml" href="/feed.xml" />
|
||||
|
||||
<!--[if IE]>
|
||||
@ -36,12 +36,13 @@
|
||||
|
||||
<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="configuration.html">Configuration</a></li>
|
||||
<li><a href="tunning.html">Tunning</a></li>
|
||||
<li><a href="faq.html">FAQ</a></li>
|
||||
</ul>
|
||||
<li><a href="installation.html">Installation</a></li>
|
||||
<li><a href="usage.html">Usage</a></li>
|
||||
<li><a href="configuration.html">Configuration</a></li>
|
||||
<li><a href="tunning.html">Tunning</a></li>
|
||||
<li><a href="faq.html">FAQ</a></li>
|
||||
<li><a href="news.html">NEWS</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
@ -88,6 +89,7 @@ $ sudo sysctl -w net.inet.ip.portrange.first="8048"
|
||||
|
||||
<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>
|
||||
|
||||
@ -36,12 +36,13 @@
|
||||
|
||||
<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="configuration.html">Configuration</a></li>
|
||||
<li><a href="tunning.html">Tunning</a></li>
|
||||
<li><a href="faq.html">FAQ</a></li>
|
||||
</ul>
|
||||
<li><a href="installation.html">Installation</a></li>
|
||||
<li><a href="usage.html">Usage</a></li>
|
||||
<li><a href="configuration.html">Configuration</a></li>
|
||||
<li><a href="tunning.html">Tunning</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">
|
||||
@ -136,6 +137,7 @@ port = 5000
|
||||
|
||||
<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>
|
||||
|
||||
@ -1,3 +1,83 @@
|
||||
template: doc.html
|
||||
title: Configuration
|
||||
|
||||
Coming soon.
|
||||
This manual to setup Gunicorn in production and use the configuration file.
|
||||
|
||||
|
||||
The configuration file
|
||||
----------------------
|
||||
|
||||
`Gunicorn`_ 0.5 introduced the ability to read configuration from a file. Gunicorn will either look for "gunicorn.conf.py" in the current directory or a file referred through the -c flag.
|
||||
|
||||
See `github.com/benoitc/gunicorn/blob/master/examples/gunicorn.conf.py.sample <http://github.com/benoitc/gunicorn/blob/master/examples/gunicorn.conf.py.sample>`_ for an example of configuration file.
|
||||
|
||||
Default configuration settings are::
|
||||
|
||||
bind='127.0.0.1:8000',
|
||||
daemon=False,
|
||||
debug=False,
|
||||
logfile='-',
|
||||
loglevel='info',
|
||||
pidfile=None,
|
||||
workers=1,
|
||||
umask=0,
|
||||
user=None,
|
||||
group=None,
|
||||
|
||||
after_fork=lambda server, worker: server.log.info(
|
||||
"worker=%s spawned pid=%s" % (worker.id, str(worker.pid))),
|
||||
|
||||
before_fork=lambda server, worker: server.log.info(
|
||||
"worker=%s spawning" % worker.id),
|
||||
|
||||
before_exec=lambda server: server.log.info("forked child, reexecuting")
|
||||
|
||||
|
||||
|
||||
after_fork:
|
||||
this function is called by the worker after forking. Arguments are the master and worker instances.
|
||||
|
||||
before_fork:
|
||||
this function is called by the worker before forking. Arguments are the master and worker instances.
|
||||
|
||||
before_exec:
|
||||
this function is called before relaunching the master. This happens when the master receive HUP or USR2 signals.
|
||||
|
||||
bind:
|
||||
address on which workers are listening. It could be a tcp address `IP:PORT` or a unix address `unix:/path/to/sockfile`.
|
||||
|
||||
daemon:
|
||||
Start in daemonized mode.
|
||||
|
||||
debug:
|
||||
if set to `True`, only one worker will be launch and`the variable `wsgi.multiprocess` will be set to False.
|
||||
|
||||
group:
|
||||
the group on which workers processes will be launched.
|
||||
|
||||
logfile:
|
||||
path to the log file. `-` (stdout) by default.
|
||||
|
||||
loglevel:
|
||||
set debug level: info, debug, error
|
||||
|
||||
pidfile:
|
||||
file where master PID number will be saved
|
||||
|
||||
umask:
|
||||
in daemon mode, fix user mask of master.
|
||||
|
||||
user:
|
||||
the user on which workers processes will be launched.
|
||||
|
||||
Production setup
|
||||
----------------
|
||||
|
||||
While some others HTTP proxies can be used we strongly advice you to use `NGINX <http://www/nginx.org>`_. If you choose another proxy server, make sure it can do buffering to handle slow clients.
|
||||
|
||||
An example config file for use with nginx is available at `github.com/benoitc/gunicorn/blob/master/examples/nginx.conf <http://github.com/benoitc/gunicorn/blob/master/examples/nginx.conf>`_.
|
||||
|
||||
|
||||
You may want to monitor `Gunicorn`_ service instead of launching it as daemon. You could for example use `runit <http://smarden.org/runit/>`_ for that purpose. An example config file for use with runit is available at `github.com/benoitc/gunicorn/blob/master/examples/gunicorn_rc <http://github.com/benoitc/gunicorn/blob/master/examples/gunicorn_rc>`_.
|
||||
|
||||
.. _Gunicorn: http://gunicorn.org
|
||||
@ -1,4 +1,5 @@
|
||||
template: doc.html
|
||||
title: FAQ
|
||||
|
||||
FAQ
|
||||
===
|
||||
|
||||
@ -22,6 +22,7 @@ Features
|
||||
- Simple and easy Python DSL for configuration
|
||||
- Decode chunked transfers on-the-fly, allowing upload progress notifications or
|
||||
stream-based protocols over HTTP.
|
||||
- post/pre fork hooks
|
||||
|
||||
.. _freenode: http://freenode.net
|
||||
.. _Gunicorn: http://gunicorn.org
|
||||
|
||||
4
doc/site/news.rst
Normal file
4
doc/site/news.rst
Normal file
@ -0,0 +1,4 @@
|
||||
template: doc.html
|
||||
title: News
|
||||
|
||||
Coming soon
|
||||
@ -1,4 +1,5 @@
|
||||
template: doc.html
|
||||
title: Tunning
|
||||
|
||||
|
||||
Gunicorn performances are good enough for most cases. Most often performances can be improved in your application.
|
||||
|
||||
1
doc/templates/base.html
vendored
1
doc/templates/base.html
vendored
@ -37,6 +37,7 @@
|
||||
|
||||
<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>
|
||||
|
||||
8
doc/templates/doc.html
vendored
8
doc/templates/doc.html
vendored
@ -5,13 +5,7 @@
|
||||
{% block body %}
|
||||
|
||||
<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="configuration.html">Configuration</a></li>
|
||||
<li><a href="tunning.html">Tunning</a></li>
|
||||
<li><a href="faq.html">FAQ</a></li>
|
||||
</ul>
|
||||
{% include "menu.html" %}
|
||||
</div>
|
||||
|
||||
{{ stuff }}
|
||||
|
||||
8
doc/templates/index.html
vendored
8
doc/templates/index.html
vendored
@ -3,12 +3,6 @@
|
||||
{% block body %}{{ stuff }}{% endblock %}
|
||||
|
||||
{% block extra %}
|
||||
<ul id="actions">
|
||||
<li><a href="installation.html">Installation</a></li>
|
||||
<li><a href="usage.html">Usage</a></li>
|
||||
<li><a href="configuration.html">Configuration</a></li>
|
||||
<li><a href="tunning.html">Tunning</a></li>
|
||||
<li><a href="faq.html">FAQ</a></li>
|
||||
</ul>
|
||||
{% include "menu.html" %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
8
doc/templates/menu.html
vendored
Normal file
8
doc/templates/menu.html
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
<ul id="actions">
|
||||
<li><a href="installation.html">Installation</a></li>
|
||||
<li><a href="usage.html">Usage</a></li>
|
||||
<li><a href="configuration.html">Configuration</a></li>
|
||||
<li><a href="tunning.html">Tunning</a></li>
|
||||
<li><a href="faq.html">FAQ</a></li>
|
||||
<li><a href="news.html">NEWS</a></li>
|
||||
</ul>
|
||||
20
examples/gunicorn.conf.py.sample
Normal file
20
examples/gunicorn.conf.py.sample
Normal file
@ -0,0 +1,20 @@
|
||||
bind='unix:/tmp/gunicorn.sock',
|
||||
daemon=True,
|
||||
debug=False,
|
||||
logfile='/var/log/gunicorn.log',
|
||||
loglevel='info',
|
||||
pidfile='/var/run/gunicorn.pid',
|
||||
workers=1,
|
||||
umask=0,
|
||||
|
||||
# for systems with nobody and no group
|
||||
user="nobody",
|
||||
group="nogroup",
|
||||
|
||||
after_fork=lambda server, worker: server.log.info(
|
||||
"worker=%s spawned pid=%s" % (worker.id, str(worker.pid))),
|
||||
|
||||
before_fork=lambda server, worker: server.log.info(
|
||||
"worker=%s spawning" % worker.id),
|
||||
|
||||
before_exec=lambda server: server.log.info("forked child, reexecuting")
|
||||
9
examples/gunicorn_rc
Executable file
9
examples/gunicorn_rc
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin sh
|
||||
|
||||
if [ -f /var/run/gunicorn.pid ]; then
|
||||
rm /var/run/gunicorn.pid
|
||||
fi
|
||||
|
||||
cd /path/to/project
|
||||
exec /usr/local/bin/gunicorn -C /path/to/project/gunicorn.conf.py \
|
||||
--pidfile=/var/run/gunicorn.pid main:application
|
||||
126
examples/nginx.conf
Normal file
126
examples/nginx.conf
Normal file
@ -0,0 +1,126 @@
|
||||
# This is example contains the bare mininum to get nginx going with
|
||||
# Gunicornservers.
|
||||
|
||||
worker_processes 1;
|
||||
|
||||
# # drop privileges, root is needed on most systems for binding to port 80
|
||||
# # (or anything < 1024). Capability-based security may be available for
|
||||
# # your system and worth checking out so you won't need to be root to
|
||||
# # start nginx to bind on 80
|
||||
user nobody nogroup; # for systems with a "nogroup"
|
||||
# user nobody nobody; # for systems with "nobody" as a group instead
|
||||
|
||||
# Feel free to change all paths to suite your needs here, of course
|
||||
pid /tmp/nginx.pid;
|
||||
error_log /tmp/nginx.error.log;
|
||||
|
||||
events {
|
||||
worker_connections 1024; # increase if you have lots of clients
|
||||
accept_mutex off; # "on" if nginx worker_processes > 1
|
||||
# use epoll; # enable for Linux 2.6+
|
||||
# use kqueue; # enable for FreeBSD, OSX
|
||||
}
|
||||
|
||||
http {
|
||||
# nginx will find this file in the config directory set at nginx build time
|
||||
include mime.types;
|
||||
|
||||
# fallback in case we can't determine a type
|
||||
default_type application/octet-stream;
|
||||
|
||||
# click tracking!
|
||||
access_log /tmp/nginx.access.log combined;
|
||||
|
||||
# you generally want to serve static files with nginx since neither
|
||||
# Unicorn nor Rainbows! is optimized for it at the moment
|
||||
sendfile on;
|
||||
|
||||
tcp_nopush on; # off may be better for *some* Comet/long-poll stuff
|
||||
tcp_nodelay off; # on may be better for some Comet/long-poll stuff
|
||||
|
||||
# we haven't checked to see if Rack::Deflate on the app server is
|
||||
# faster or not than doing compression via nginx. It's easier
|
||||
# to configure it all in one place here for static files and also
|
||||
# to disable gzip for clients who don't get gzip/deflate right.
|
||||
# There are other other gzip settings that may be needed used to deal with
|
||||
# bad clients out there, see http://wiki.nginx.org/NginxHttpGzipModule
|
||||
gzip on;
|
||||
gzip_http_version 1.0;
|
||||
gzip_proxied any;
|
||||
gzip_min_length 500;
|
||||
gzip_disable "MSIE [1-6]\.";
|
||||
gzip_types text/plain text/html text/xml text/css
|
||||
text/comma-separated-values
|
||||
text/javascript application/x-javascript
|
||||
application/atom+xml;
|
||||
|
||||
# this can be any application server, not just Unicorn/Rainbows!
|
||||
upstream app_server {
|
||||
# fail_timeout=0 means we always retry an upstream even if it failed
|
||||
# to return a good HTTP response (in case the Unicorn master nukes a
|
||||
# single worker for timing out).
|
||||
|
||||
# for UNIX domain socket setups:
|
||||
server unix:/tmp/gunicorn.sock fail_timeout=0;
|
||||
|
||||
# for TCP setups, point these to your backend servers
|
||||
# server 192.168.0.7:8080 fail_timeout=0;
|
||||
# server 192.168.0.8:8080 fail_timeout=0;
|
||||
# server 192.168.0.9:8080 fail_timeout=0;
|
||||
}
|
||||
|
||||
server {
|
||||
# listen 80 default deferred; # for Linux
|
||||
# listen 80 default accept_filter=httpready; # for FreeBSD
|
||||
listen 80 default;
|
||||
|
||||
client_max_body_size 4G;
|
||||
server_name _;
|
||||
|
||||
# ~2 seconds is often enough for most folks to parse HTML/CSS and
|
||||
# retrieve needed images/icons/frames, connections are cheap in
|
||||
# nginx so increasing this is generally safe...
|
||||
keepalive_timeout 5;
|
||||
|
||||
# path for static files
|
||||
root /path/to/app/current/public;
|
||||
|
||||
location / {
|
||||
# an HTTP header important enough to have its own Wikipedia entry:
|
||||
# http://en.wikipedia.org/wiki/X-Forwarded-For
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
# enable this if and only if you use HTTPS, this helps Rack
|
||||
# set the proper protocol for doing redirects:
|
||||
# proxy_set_header X-Forwarded-Proto https;
|
||||
|
||||
# pass the Host: header from the client right along so redirects
|
||||
# can be set properly within the Rack application
|
||||
proxy_set_header Host $http_host;
|
||||
|
||||
# we don't want nginx trying to do something clever with
|
||||
# redirects, we set the Host: header above already.
|
||||
proxy_redirect off;
|
||||
|
||||
# set "proxy_buffering off" *only* for Rainbows! when doing
|
||||
# Comet/long-poll stuff. It's also safe to set if you're
|
||||
# using only serving fast clients with Unicorn + nginx.
|
||||
# Otherwise you _want_ nginx to buffer responses to slow
|
||||
# clients, really.
|
||||
# proxy_buffering off;
|
||||
|
||||
# Try to serve static files from nginx, no point in making an
|
||||
# *application* server like Unicorn/Rainbows! serve static files.
|
||||
if (!-f $request_filename) {
|
||||
proxy_pass http://app_server;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
# Rails error pages
|
||||
error_page 500 502 503 504 /500.html;
|
||||
location = /500.html {
|
||||
root /path/to/app/current/public;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user