forked from benoitc/gunicorn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.html
760 lines (758 loc) · 32.7 KB
/
configure.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Green Unicorn - Configure</title>
<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="community.html">Community</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="overview">
<h2><a class="toc-backref" href="#contents">Overview</a></h2>
<p>Gunicorn pulls configuration information from three distinct places.</p>
<p>The first place that Gunicorn will read configuration from is the framework
specific configuration file. Currently this only affects Paster applications.</p>
<p>The second source of configuration information is a configuration file that is
optionally specified on the command line. Anything specified in the Gunicorn
config file will override any framework specific settings.</p>
<p>Lastly, the command line arguments used to invoke Gunicorn are the final place
considered for configuration settings. If an option is specified on the command
line, this is the value that will be used.</p>
<dl class="docutils">
<dt>Once again, in order of least to most authoritative:</dt>
<dd><ol class="first last arabic simple">
<li>Framework Settings</li>
<li>Configuration File</li>
<li>Command Line</li>
</ol>
</dd>
</dl>
</div>
<div class="section" id="framework-settings">
<h2><a class="toc-backref" href="#contents">Framework Settings</a></h2>
<p>Currently, only Paster applications have access to framework specific
settings. If you have ideas for providing settings to WSGI applications or
pulling information from Django's settings.py feel free to open an <a class="reference external" href="http://github.com/benoitc/gunicorn/issues">issue</a> to
let us know.</p>
<div class="section" id="paster-applications">
<h3><a class="toc-backref" href="#contents">Paster Applications</a></h3>
<p>In your INI file, you can specify to use Gunicorn as the server like such:</p>
<pre class="literal-block">
[server:main]
use = egg:gunicorn#main
host = 192.168.0.1
port = 80
workers = 2
proc_name = brim
</pre>
<p>Any parameters that Gunicorn knows about will automatically be inserted into
the base configuration. Remember that these will be overridden by the config
file and/or the command line.</p>
</div>
</div>
<div class="section" id="configuration-file">
<h2><a class="toc-backref" href="#contents">Configuration File</a></h2>
<p>The configuration file should be a valid Python source file. It only needs to
be readable from the file system. More specifically, it does not need to be
importable. Any Python is valid. Just consider that this will be run every time
you start Gunicorn (including when you signal Gunicorn to reload).</p>
<p>To set a parameter, just assign to it. There's no special syntax. The values
you provide will be used for the configuration values.</p>
<p>For instance:</p>
<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
def numCPUs():
if not hasattr(os, "sysconf"):
raise RuntimeError("No sysconf detected.")
return os.sysconf("SC_NPROCESSORS_ONLN")
</pre>
</div>
<div class="section" id="command-line">
<h2><a class="toc-backref" href="#contents">Command Line</a></h2>
<p>If an option is specified on the command line, it overrides all other values
that may have been specified in the app specific settings, or in the optional
configuration file. Not all Gunicorn settings are available to be set from the
command line. To see the full list of command line settings you can do the
usual:</p>
<pre class="literal-block">
$ gunicorn -h
</pre>
<p>There is also a <tt class="docutils literal"><span class="pre">--version</span></tt> flag available to the command line scripts that
isn't mentioned in the list of settings.</p>
</div>
<div class="section" id="settings">
<h2><a class="toc-backref" href="#contents">Settings</a></h2>
<p>This is an exhaustive list of settings for Gunicorn. Some settings are only
able to be set from a configuration file. The setting name is what should be
used in the configuration file. The command line arguments are listed as well
for reference on setting at the command line.</p>
<div class="section" id="config-file">
<h3><a class="toc-backref" href="#contents">Config File</a></h3>
<div class="section" id="config">
<h4><a class="toc-backref" href="#contents">config</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">-c</span> FILE, <span class="pre">--config</span> FILE</tt></li>
<li><tt class="docutils literal">None</tt></li>
</ul>
<p>The path to a Gunicorn config file.</p>
<p>Only has an effect when specified on the command line or as part of an
application specific configuration.</p>
</div>
</div>
<div class="section" id="server-socket">
<h3><a class="toc-backref" href="#contents">Server Socket</a></h3>
<div class="section" id="bind">
<h4><a class="toc-backref" href="#contents">bind</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">-b</span> ADDRESS, <span class="pre">--bind</span> ADDRESS</tt></li>
<li><tt class="docutils literal">127.0.0.1:8000</tt></li>
</ul>
<p>The socket to bind.</p>
<p>A string of the form: 'HOST', 'HOST:PORT', 'unix:PATH'. An IP is a valid
HOST.</p>
</div>
<div class="section" id="backlog">
<h4><a class="toc-backref" href="#contents">backlog</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">--backlog</span> INT</tt></li>
<li><tt class="docutils literal">2048</tt></li>
</ul>
<p>The maximum number of pending connections.</p>
<p>This refers to the number of clients that can be waiting to be served.
Exceeding this number results in the client getting an error when
attempting to connect. It should only affect servers under significant
load.</p>
<p>Must be a positive integer. Generally set in the 64-2048 range.</p>
</div>
</div>
<div class="section" id="worker-processes">
<h3><a class="toc-backref" href="#contents">Worker Processes</a></h3>
<div class="section" id="workers">
<h4><a class="toc-backref" href="#contents">workers</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">-w</span> INT, <span class="pre">--workers</span> INT</tt></li>
<li><tt class="docutils literal">1</tt></li>
</ul>
<p>The number of worker process for handling requests.</p>
<p>A positive integer generally in the 2-4 x $(NUM_CORES) range. You'll
want to vary this a bit to find the best for your particular
application's work load.</p>
</div>
<div class="section" id="worker-class">
<h4><a class="toc-backref" href="#contents">worker_class</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">-k</span> STRING, <span class="pre">--worker-class</span> STRING</tt></li>
<li><tt class="docutils literal">sync</tt></li>
</ul>
<p>The type of workers to use.</p>
<p>The default class (sync) should handle most 'normal' types of workloads.
You'll want to read <a class="reference external" href="http://gunicorn.org/design.html">http://gunicorn.org/design.html</a> for information on
when you might want to choose one of the other worker classes.</p>
<p>A string referring to one of the following bundled classes:</p>
<ul class="simple">
<li><tt class="docutils literal">sync</tt></li>
<li><tt class="docutils literal">eventlet</tt> - Requires eventlet >= 0.9.7</li>
<li><tt class="docutils literal">gevent</tt> - Requires gevent >= 0.12.2 (?)</li>
<li><tt class="docutils literal">tornado</tt> - Requires tornado >= 0.2</li>
</ul>
<p>Optionally, you can provide your own worker by giving gunicorn a
python path to a subclass of gunicorn.workers.base.Worker. This
alternative syntax will load the gevent class:
<tt class="docutils literal">gunicorn.workers.ggevent.GeventWorker</tt>. Alternatively the syntax
can also load the gevent class with <tt class="docutils literal">egg:gunicorn#gevent</tt></p>
</div>
<div class="section" id="worker-connections">
<h4><a class="toc-backref" href="#contents">worker_connections</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">--worker-connections</span> INT</tt></li>
<li><tt class="docutils literal">1000</tt></li>
</ul>
<p>The maximum number of simultaneous clients.</p>
<p>This setting only affects the Eventlet and Gevent worker types.</p>
</div>
<div class="section" id="max-requests">
<h4><a class="toc-backref" href="#contents">max_requests</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">--max-requests</span> INT</tt></li>
<li><tt class="docutils literal">0</tt></li>
</ul>
<p>The maximum number of requests a worker will process before restarting.</p>
<p>Any value greater than zero will limit the number of requests a work
will process before automatically restarting. This is a simple method
to help limit the damage of memory leaks.</p>
<p>If this is set to zero (the default) then the automatic worker
restarts are disabled.</p>
</div>
<div class="section" id="timeout">
<h4><a class="toc-backref" href="#contents">timeout</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">-t</span> INT, <span class="pre">--timeout</span> INT</tt></li>
<li><tt class="docutils literal">30</tt></li>
</ul>
<p>Workers silent for more than this many seconds are killed and restarted.</p>
<p>Generally set to thirty seconds. Only set this noticeably higher if
you're sure of the repercussions for sync workers. For the non sync
workers it just means that the worker process is still communicating and
is not tied to the length of time required to handle a single request.</p>
</div>
<div class="section" id="keepalive">
<h4><a class="toc-backref" href="#contents">keepalive</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">--keep-alive</span> INT</tt></li>
<li><tt class="docutils literal">2</tt></li>
</ul>
<p>The number of seconds to wait for requests on a Keep-Alive connection.</p>
<p>Generally set in the 1-5 seconds range.</p>
</div>
</div>
<div class="section" id="security">
<h3><a class="toc-backref" href="#contents">Security</a></h3>
<div class="section" id="limit-request-line">
<h4><a class="toc-backref" href="#contents">limit_request_line</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">--limit-request-line</span> INT</tt></li>
<li><tt class="docutils literal">4094</tt></li>
</ul>
<p>The maximum size of HTTP request line in bytes.</p>
<p>This parameter is used to limit the allowed size of a client's
HTTP request-line. Since the request-line consists of the HTTP
method, URI, and protocol version, this directive places a
restriction on the length of a request-URI allowed for a request
on the server. A server needs this value to be large enough to
hold any of its resource names, including any information that
might be passed in the query part of a GET request. By default
this value is 4094 and can't be larger than 8190.</p>
<p>This parameter can be used to prevent any DDOS attack.</p>
</div>
<div class="section" id="limit-request-fields">
<h4><a class="toc-backref" href="#contents">limit_request_fields</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">--limit-request-fields</span> INT</tt></li>
<li><tt class="docutils literal">100</tt></li>
</ul>
<p>Limit the number of HTTP headers fields in a request.</p>
<p>Value is a number from 0 (unlimited) to 32768. This parameter is
used to limit the number of headers in a request to prevent DDOS
attack. Used with the <cite>limit_request_field_size</cite> it allows more
safety.</p>
</div>
<div class="section" id="limit-request-field-size">
<h4><a class="toc-backref" href="#contents">limit_request_field_size</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">--limit-request-field_size</span> INT</tt></li>
<li><tt class="docutils literal">8190</tt></li>
</ul>
<p>Limit the allowed size of an HTTP request header field.</p>
<p>Value is a number from 0 (unlimited) to 8190. to set the limit
on the allowed size of an HTTP request header field.</p>
</div>
</div>
<div class="section" id="debugging">
<h3><a class="toc-backref" href="#contents">Debugging</a></h3>
<div class="section" id="debug">
<h4><a class="toc-backref" href="#contents">debug</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">--debug</span></tt></li>
<li><tt class="docutils literal">False</tt></li>
</ul>
<p>Turn on debugging in the server.</p>
<p>This limits the number of worker processes to 1 and changes some error
handling that's sent to clients.</p>
</div>
<div class="section" id="spew">
<h4><a class="toc-backref" href="#contents">spew</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">--spew</span></tt></li>
<li><tt class="docutils literal">False</tt></li>
</ul>
<p>Install a trace function that spews every line executed by the server.</p>
<p>This is the nuclear option.</p>
</div>
<div class="section" id="check-config">
<h4><a class="toc-backref" href="#contents">check_config</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">--check-config</span></tt></li>
<li><tt class="docutils literal">False</tt></li>
</ul>
<p>Check the configuration..</p>
</div>
</div>
<div class="section" id="server-mechanics">
<h3><a class="toc-backref" href="#contents">Server Mechanics</a></h3>
<div class="section" id="preload-app">
<h4><a class="toc-backref" href="#contents">preload_app</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">--preload</span></tt></li>
<li><tt class="docutils literal">False</tt></li>
</ul>
<p>Load application code before the worker processes are forked.</p>
<p>By preloading an application you can save some RAM resources as well as
speed up server boot times. Although, if you defer application loading
to each worker process, you can reload your application code easily by
restarting workers.</p>
</div>
<div class="section" id="daemon">
<h4><a class="toc-backref" href="#contents">daemon</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">-D,</span> <span class="pre">--daemon</span></tt></li>
<li><tt class="docutils literal">False</tt></li>
</ul>
<p>Daemonize the Gunicorn process.</p>
<p>Detaches the server from the controlling terminal and enters the
background.</p>
</div>
<div class="section" id="pidfile">
<h4><a class="toc-backref" href="#contents">pidfile</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">-p</span> FILE, <span class="pre">--pid</span> FILE</tt></li>
<li><tt class="docutils literal">None</tt></li>
</ul>
<p>A filename to use for the PID file.</p>
<p>If not set, no PID file will be written.</p>
</div>
<div class="section" id="user">
<h4><a class="toc-backref" href="#contents">user</a></h4>
<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">501</tt></li>
</ul>
<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
retrieved with a call to pwd.getpwnam(value) or None to not change
the worker process user.</p>
</div>
<div class="section" id="group">
<h4><a class="toc-backref" href="#contents">group</a></h4>
<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">20</tt></li>
</ul>
<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
retrieved with a call to pwd.getgrnam(value) or None to not change
the worker processes group.</p>
</div>
<div class="section" id="umask">
<h4><a class="toc-backref" href="#contents">umask</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">-m</span> INT, <span class="pre">--umask</span> INT</tt></li>
<li><tt class="docutils literal">0</tt></li>
</ul>
<p>A bit mask for the file mode on files written by Gunicorn.</p>
<p>Note that this affects unix socket permissions.</p>
<p>A valid value for the os.umask(mode) call or a string compatible with
int(value, 0) (0 means Python guesses the base, so values like "0",
"0xFF", "0022" are valid for decimal, hex, and octal representations)</p>
</div>
<div class="section" id="tmp-upload-dir">
<h4><a class="toc-backref" href="#contents">tmp_upload_dir</a></h4>
<ul class="simple">
<li><tt class="docutils literal">None</tt></li>
</ul>
<p>Directory to store temporary request data as they are read.</p>
<p>This may disappear in the near future.</p>
<p>This path should be writable by the process permissions set for Gunicorn
workers. If not specified, Gunicorn will choose a system generated
temporary directory.</p>
</div>
<div class="section" id="secure-scheme-headers">
<h4><a class="toc-backref" href="#contents">secure_scheme_headers</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">{'X-FORWARDED-PROTOCOL':</span> 'ssl', <span class="pre">'X-FORWARDED-SSL':</span> 'on'}</tt></li>
</ul>
<p>A dictionary containing headers and values that the front-end proxy
uses to indicate HTTPS requests. These tell gunicorn to set
wsgi.url_scheme to "https", so your application can tell that the
request is secure.</p>
<p>The dictionary should map upper-case header names to exact string
values. The value comparisons are case-sensitive, unlike the header
names, so make sure they're exactly what your front-end proxy sends
when handling HTTPS requests.</p>
<p>It is important that your front-end proxy configuration ensures that
the headers defined here can not be passed directly from the client.</p>
</div>
<div class="section" id="x-forwarded-for-header">
<h4><a class="toc-backref" href="#contents">x_forwarded_for_header</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">X-FORWARDED-FOR</span></tt></li>
</ul>
<p>Set the X-Forwarded-For header that identify the originating IP
address of the client connection to gunicorn via a proxy.</p>
</div>
</div>
<div class="section" id="logging">
<h3><a class="toc-backref" href="#contents">Logging</a></h3>
<div class="section" id="accesslog">
<h4><a class="toc-backref" href="#contents">accesslog</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">--access-logfile</span> FILE</tt></li>
<li><tt class="docutils literal">None</tt></li>
</ul>
<p>The Access log file to write to.</p>
<p>"-" means log to stdout.</p>
</div>
<div class="section" id="access-log-format">
<h4><a class="toc-backref" href="#contents">access_log_format</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">--access-logformat</span> STRING</tt></li>
<li><tt class="docutils literal"><span class="pre">"%(h)s</span> %(l)s %(u)s %(t)s <span class="pre">"%(r)s"</span> %(s)s %(b)s <span class="pre">"%(f)s"</span> <span class="pre">"%(a)s"</span></tt></li>
</ul>
<p>The Access log format .</p>
<p>By default:</p>
<p>%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"</p>
<p>h: remote address
l: '-'
u: currently '-', may be user name in future releases
t: date of the request
r: status line (ex: GET / HTTP/1.1)
s: status
b: response length or '-'
f: referer
a: user agent
T: request time in seconds
D: request time in microseconds,
p: process ID
{Header}i: request header
{Header}o: response header</p>
</div>
<div class="section" id="errorlog">
<h4><a class="toc-backref" href="#contents">errorlog</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">--error-logfile</span> FILE, <span class="pre">--log-file</span> FILE</tt></li>
<li><tt class="docutils literal">-</tt></li>
</ul>
<p>The Error log file to write to.</p>
<p>"-" means log to stdout.</p>
</div>
<div class="section" id="loglevel">
<h4><a class="toc-backref" href="#contents">loglevel</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">--log-level</span> LEVEL</tt></li>
<li><tt class="docutils literal">info</tt></li>
</ul>
<p>The granularity of Error log outputs.</p>
<p>Valid level names are:</p>
<ul class="simple">
<li>debug</li>
<li>info</li>
<li>warning</li>
<li>error</li>
<li>critical</li>
</ul>
</div>
<div class="section" id="logger-class">
<h4><a class="toc-backref" href="#contents">logger_class</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">--logger-class</span> STRING</tt></li>
<li><tt class="docutils literal">simple</tt></li>
</ul>
<p>The logger you want to use to log events in gunicorn.</p>
<p>The default class (<tt class="docutils literal">gunicorn.glogging.Logger</tt>) handle most of
normal usages in logging. It provides error and access logging.</p>
<p>You can provide your own worker by giving gunicorn a
python path to a subclass like gunicorn.glogging.Logger.
Alternatively the syntax can also load the Logger class
with <cite>egg:gunicorn#simple</cite></p>
</div>
<div class="section" id="logconfig">
<h4><a class="toc-backref" href="#contents">logconfig</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">--log-config</span> FILE</tt></li>
<li><tt class="docutils literal">None</tt></li>
</ul>
<p>The log config file to use.
Gunicorn uses the standard Python logging module's Configuration
file format.</p>
</div>
</div>
<div class="section" id="process-naming">
<h3><a class="toc-backref" href="#contents">Process Naming</a></h3>
<div class="section" id="proc-name">
<h4><a class="toc-backref" href="#contents">proc_name</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">-n</span> STRING, <span class="pre">--name</span> STRING</tt></li>
<li><tt class="docutils literal">None</tt></li>
</ul>
<p>A base to use with setproctitle for process naming.</p>
<p>This affects things like <tt class="docutils literal">ps</tt> and <tt class="docutils literal">top</tt>. If you're going to be
running more than one instance of Gunicorn you'll probably want to set a
name to tell them apart. This requires that you install the setproctitle
module.</p>
<p>It defaults to 'gunicorn'.</p>
</div>
<div class="section" id="default-proc-name">
<h4><a class="toc-backref" href="#contents">default_proc_name</a></h4>
<ul class="simple">
<li><tt class="docutils literal">gunicorn</tt></li>
</ul>
<p>Internal setting that is adjusted for each type of application.</p>
</div>
</div>
<div class="section" id="django">
<h3><a class="toc-backref" href="#contents">Django</a></h3>
<div class="section" id="django-settings">
<h4><a class="toc-backref" href="#contents">django_settings</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">--settings</span> STRING</tt></li>
<li><tt class="docutils literal">None</tt></li>
</ul>
<p>The Python path to a Django settings module.</p>
<p>e.g. 'myproject.settings.main'. If this isn't provided, the
DJANGO_SETTINGS_MODULE environment variable will be used.</p>
</div>
<div class="section" id="pythonpath">
<h4><a class="toc-backref" href="#contents">pythonpath</a></h4>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">--pythonpath</span> STRING</tt></li>
<li><tt class="docutils literal">None</tt></li>
</ul>
<p>A directory to add to the Python path for Django.</p>
<p>e.g.
'/home/djangoprojects/myproject'.</p>
</div>
</div>
<div class="section" id="server-hooks">
<h3><a class="toc-backref" href="#contents">Server Hooks</a></h3>
<div class="section" id="on-starting">
<h4><a class="toc-backref" href="#contents">on_starting</a></h4>
<ul>
<li><pre class="first literal-block">
def on_starting(server):
pass
</pre>
</li>
</ul>
<p>Called just before the master process is initialized.</p>
<p>The callable needs to accept a single instance variable for the Arbiter.</p>
</div>
<div class="section" id="on-reload">
<h4><a class="toc-backref" href="#contents">on_reload</a></h4>
<ul>
<li><pre class="first literal-block">
def on_reload(server):
for i in range(server.app.cfg.workers):
server.spawn_worker()
</pre>
</li>
</ul>
<p>Called to recycle workers during a reload via SIGHUP.</p>
<p>The callable needs to accept a single instance variable for the Arbiter.</p>
</div>
<div class="section" id="when-ready">
<h4><a class="toc-backref" href="#contents">when_ready</a></h4>
<ul>
<li><pre class="first literal-block">
def when_ready(server):
pass
</pre>
</li>
</ul>
<p>Called just after the server is started.</p>
<p>The callable needs to accept a single instance variable for the Arbiter.</p>
</div>
<div class="section" id="pre-fork">
<h4><a class="toc-backref" href="#contents">pre_fork</a></h4>
<ul>
<li><pre class="first literal-block">
def pre_fork(server, worker):
pass
</pre>
</li>
</ul>
<p>Called just before a worker is forked.</p>
<p>The callable needs to accept two instance variables for the Arbiter and
new Worker.</p>
</div>
<div class="section" id="post-fork">
<h4><a class="toc-backref" href="#contents">post_fork</a></h4>
<ul>
<li><pre class="first literal-block">
def post_fork(server, worker):
pass
</pre>
</li>
</ul>
<p>Called just after a worker has been forked.</p>
<p>The callable needs to accept two instance variables for the Arbiter and
new Worker.</p>
</div>
<div class="section" id="pre-exec">
<h4><a class="toc-backref" href="#contents">pre_exec</a></h4>
<ul>
<li><pre class="first literal-block">
def pre_exec(server):
pass
</pre>
</li>
</ul>
<p>Called just before a new master process is forked.</p>
<p>The callable needs to accept a single instance variable for the Arbiter.</p>
</div>
<div class="section" id="pre-request">
<h4><a class="toc-backref" href="#contents">pre_request</a></h4>
<ul>
<li><pre class="first literal-block">
def pre_request(worker, req):
worker.log.debug("%s %s" % (req.method, req.path))
</pre>
</li>
</ul>
<p>Called just before a worker processes the request.</p>
<p>The callable needs to accept two instance variables for the Worker and
the Request.</p>
</div>
<div class="section" id="post-request">
<h4><a class="toc-backref" href="#contents">post_request</a></h4>
<ul>
<li><pre class="first literal-block">
def post_request(worker, req, environ):
pass
</pre>
</li>
</ul>
<p>Called after a worker processes the request.</p>
<p>The callable needs to accept two instance variables for the Worker and
the Request.</p>
</div>
<div class="section" id="worker-exit">
<h4><a class="toc-backref" href="#contents">worker_exit</a></h4>
<ul>
<li><pre class="first literal-block">
def worker_exit(server, worker):
pass
</pre>
</li>
</ul>
<p>Called just after a worker has been exited.</p>
<p>The callable needs to accept two instance variables for the Arbiter and
the just-exited Worker.</p>
</div>
</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="#overview" id="id1">Overview</a></li>
<li><a class="reference internal" href="#framework-settings" id="id2">Framework Settings</a><ul>
<li><a class="reference internal" href="#paster-applications" id="id3">Paster Applications</a></li>
</ul>
</li>
<li><a class="reference internal" href="#configuration-file" id="id4">Configuration File</a></li>
<li><a class="reference internal" href="#command-line" id="id5">Command Line</a></li>
<li><a class="reference internal" href="#settings" id="id6">Settings</a><ul>
<li><a class="reference internal" href="#config-file" id="id7">Config File</a><ul>
<li><a class="reference internal" href="#config" id="id8">config</a></li>
</ul>
</li>
<li><a class="reference internal" href="#server-socket" id="id9">Server Socket</a><ul>
<li><a class="reference internal" href="#bind" id="id10">bind</a></li>
<li><a class="reference internal" href="#backlog" id="id11">backlog</a></li>
</ul>
</li>
<li><a class="reference internal" href="#worker-processes" id="id12">Worker Processes</a><ul>
<li><a class="reference internal" href="#workers" id="id13">workers</a></li>
<li><a class="reference internal" href="#worker-class" id="id14">worker_class</a></li>
<li><a class="reference internal" href="#worker-connections" id="id15">worker_connections</a></li>
<li><a class="reference internal" href="#max-requests" id="id16">max_requests</a></li>
<li><a class="reference internal" href="#timeout" id="id17">timeout</a></li>
<li><a class="reference internal" href="#keepalive" id="id18">keepalive</a></li>
</ul>
</li>
<li><a class="reference internal" href="#security" id="id19">Security</a><ul>
<li><a class="reference internal" href="#limit-request-line" id="id20">limit_request_line</a></li>
<li><a class="reference internal" href="#limit-request-fields" id="id21">limit_request_fields</a></li>
<li><a class="reference internal" href="#limit-request-field-size" id="id22">limit_request_field_size</a></li>
</ul>
</li>
<li><a class="reference internal" href="#debugging" id="id23">Debugging</a><ul>
<li><a class="reference internal" href="#debug" id="id24">debug</a></li>
<li><a class="reference internal" href="#spew" id="id25">spew</a></li>
<li><a class="reference internal" href="#check-config" id="id26">check_config</a></li>
</ul>
</li>
<li><a class="reference internal" href="#server-mechanics" id="id27">Server Mechanics</a><ul>
<li><a class="reference internal" href="#preload-app" id="id28">preload_app</a></li>
<li><a class="reference internal" href="#daemon" id="id29">daemon</a></li>
<li><a class="reference internal" href="#pidfile" id="id30">pidfile</a></li>
<li><a class="reference internal" href="#user" id="id31">user</a></li>
<li><a class="reference internal" href="#group" id="id32">group</a></li>
<li><a class="reference internal" href="#umask" id="id33">umask</a></li>
<li><a class="reference internal" href="#tmp-upload-dir" id="id34">tmp_upload_dir</a></li>
<li><a class="reference internal" href="#secure-scheme-headers" id="id35">secure_scheme_headers</a></li>
<li><a class="reference internal" href="#x-forwarded-for-header" id="id36">x_forwarded_for_header</a></li>
</ul>
</li>
<li><a class="reference internal" href="#logging" id="id37">Logging</a><ul>
<li><a class="reference internal" href="#accesslog" id="id38">accesslog</a></li>
<li><a class="reference internal" href="#access-log-format" id="id39">access_log_format</a></li>
<li><a class="reference internal" href="#errorlog" id="id40">errorlog</a></li>
<li><a class="reference internal" href="#loglevel" id="id41">loglevel</a></li>
<li><a class="reference internal" href="#logger-class" id="id42">logger_class</a></li>
<li><a class="reference internal" href="#logconfig" id="id43">logconfig</a></li>
</ul>
</li>
<li><a class="reference internal" href="#process-naming" id="id44">Process Naming</a><ul>
<li><a class="reference internal" href="#proc-name" id="id45">proc_name</a></li>
<li><a class="reference internal" href="#default-proc-name" id="id46">default_proc_name</a></li>
</ul>
</li>
<li><a class="reference internal" href="#django" id="id47">Django</a><ul>
<li><a class="reference internal" href="#django-settings" id="id48">django_settings</a></li>
<li><a class="reference internal" href="#pythonpath" id="id49">pythonpath</a></li>
</ul>
</li>
<li><a class="reference internal" href="#server-hooks" id="id50">Server Hooks</a><ul>
<li><a class="reference internal" href="#on-starting" id="id51">on_starting</a></li>
<li><a class="reference internal" href="#on-reload" id="id52">on_reload</a></li>
<li><a class="reference internal" href="#when-ready" id="id53">when_ready</a></li>
<li><a class="reference internal" href="#pre-fork" id="id54">pre_fork</a></li>
<li><a class="reference internal" href="#post-fork" id="id55">post_fork</a></li>
<li><a class="reference internal" href="#pre-exec" id="id56">pre_exec</a></li>
<li><a class="reference internal" href="#pre-request" id="id57">pre_request</a></li>
<li><a class="reference internal" href="#post-request" id="id58">post_request</a></li>
<li><a class="reference internal" href="#worker-exit" id="id59">worker_exit</a></li>
</ul>
</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>