mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Use the newer cpu_count method in docs.
Updated docs to show the use of the cpu_count function in the multiprocessing module. Thanks to Fabian Topfstedt for the update. Fixes #202
This commit is contained in:
parent
0b094ca08a
commit
c71b9a88c2
1
THANKS
1
THANKS
@ -26,3 +26,4 @@ Neil Chintomby <nchintomby@gmail.com>
|
|||||||
Alex Robbins <alexander.j.robbins@gmail.com>
|
Alex Robbins <alexander.j.robbins@gmail.com>
|
||||||
Graham Dumpleton <Graham.Dumpleton@gmail.com>
|
Graham Dumpleton <Graham.Dumpleton@gmail.com>
|
||||||
Dan Sully <daniel-github@electricrain.com>
|
Dan Sully <daniel-github@electricrain.com>
|
||||||
|
Fabian Topfstedt <topfstedt@schneevonmorgen.com>
|
||||||
|
|||||||
@ -81,15 +81,20 @@ you start Gunicorn (including when you signal Gunicorn to reload).</p>
|
|||||||
you provide will be used for the configuration values.</p>
|
you provide will be used for the configuration values.</p>
|
||||||
<p>For instance:</p>
|
<p>For instance:</p>
|
||||||
<pre class="literal-block">
|
<pre class="literal-block">
|
||||||
|
import multiprocessing
|
||||||
|
|
||||||
|
bind = "127.0.0.1:8000"
|
||||||
|
workers = multiprocessing.cpu_count() * 2 + 1
|
||||||
|
</pre>
|
||||||
|
<p>On a side note, Python's older than 2.6 can use sysconf to get the
|
||||||
|
number of processors:</p>
|
||||||
|
<pre class="literal-block">
|
||||||
import os
|
import os
|
||||||
|
|
||||||
def numCPUs():
|
def numCPUs():
|
||||||
if not hasattr(os, "sysconf"):
|
if not hasattr(os, "sysconf"):
|
||||||
raise RuntimeError("No sysconf detected.")
|
raise RuntimeError("No sysconf detected.")
|
||||||
return os.sysconf("SC_NPROCESSORS_ONLN")
|
return os.sysconf("SC_NPROCESSORS_ONLN")
|
||||||
|
|
||||||
bind = "127.0.0.1:8000"
|
|
||||||
workers = numCPUs() * 2 + 1
|
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="command-line">
|
<div class="section" id="command-line">
|
||||||
@ -288,7 +293,7 @@ background.</p>
|
|||||||
<h4><a class="toc-backref" href="#contents">user</a></h4>
|
<h4><a class="toc-backref" href="#contents">user</a></h4>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li><tt class="docutils literal"><span class="pre">-u</span> USER, <span class="pre">--user</span> USER</tt></li>
|
<li><tt class="docutils literal"><span class="pre">-u</span> USER, <span class="pre">--user</span> USER</tt></li>
|
||||||
<li><tt class="docutils literal">501</tt></li>
|
<li><tt class="docutils literal">1744020413</tt></li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>Switch worker processes to run as this user.</p>
|
<p>Switch worker processes to run as this user.</p>
|
||||||
<p>A valid user id (as an integer) or the name of a user that can be
|
<p>A valid user id (as an integer) or the name of a user that can be
|
||||||
@ -299,7 +304,7 @@ the worker process user.</p>
|
|||||||
<h4><a class="toc-backref" href="#contents">group</a></h4>
|
<h4><a class="toc-backref" href="#contents">group</a></h4>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li><tt class="docutils literal"><span class="pre">-g</span> GROUP, <span class="pre">--group</span> GROUP</tt></li>
|
<li><tt class="docutils literal"><span class="pre">-g</span> GROUP, <span class="pre">--group</span> GROUP</tt></li>
|
||||||
<li><tt class="docutils literal">20</tt></li>
|
<li><tt class="docutils literal">2093627230</tt></li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>Switch worker process to run as this group.</p>
|
<p>Switch worker process to run as this group.</p>
|
||||||
<p>A valid group id (as an integer) or the name of a user that can be
|
<p>A valid group id (as an integer) or the name of a user that can be
|
||||||
|
|||||||
@ -69,6 +69,14 @@ you provide will be used for the configuration values.
|
|||||||
|
|
||||||
For instance::
|
For instance::
|
||||||
|
|
||||||
|
import multiprocessing
|
||||||
|
|
||||||
|
bind = "127.0.0.1:8000"
|
||||||
|
workers = multiprocessing.cpu_count() * 2 + 1
|
||||||
|
|
||||||
|
On a side note, Python's older than 2.6 can use sysconf to get the
|
||||||
|
number of processors::
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
def numCPUs():
|
def numCPUs():
|
||||||
@ -76,9 +84,6 @@ For instance::
|
|||||||
raise RuntimeError("No sysconf detected.")
|
raise RuntimeError("No sysconf detected.")
|
||||||
return os.sysconf("SC_NPROCESSORS_ONLN")
|
return os.sysconf("SC_NPROCESSORS_ONLN")
|
||||||
|
|
||||||
bind = "127.0.0.1:8000"
|
|
||||||
workers = numCPUs() * 2 + 1
|
|
||||||
|
|
||||||
Command Line
|
Command Line
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user