~ubuntu-branches/ubuntu/maverick/gunicorn/maverick

« back to all changes in this revision

Viewing changes to examples/gunicorn.conf.py.sample

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2010-07-16 10:44:12 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100716104412-iddgoj0lss2hxg7q
Tags: 0.10.0-1
* New upstream release.
* Add python-setproctitle to Suggests. Thanks to Örjan Persson
  <orange@fobie.net>.
* Bump Standards-Version to 3.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Sample Gunicorn configuration file.
2
 
 
3
 
#
4
 
# Server socket
5
 
#
6
 
#   bind - The socket to bind.
7
 
#
8
 
#       A string of the form: 'HOST', 'HOST:PORT', 'unix:PATH'.
9
 
#       An IP is a valid HOST.
10
 
#
11
 
#   backlog - The number of pending connections. This refers
12
 
#       to the number of clients that can be waiting to be
13
 
#       served. Exceeding this number results in the client
14
 
#       getting an error when attempting to connect. It should
15
 
#       only affect servers under significant load.
16
 
#
17
 
#       Must be a positive integer. Generally set in the 64-2048
18
 
#       range.
19
 
#
20
 
 
21
 
bind = '127.0.0.1:8000'
22
 
backlog = 2048
23
 
 
24
 
#
25
 
# Worker processes
26
 
#
27
 
#   workers - The number of worker processes that this server
28
 
#       should keep alive for handling requests.
29
 
#
30
 
#       A positive integer generally in the 2-4 x $(NUM_CORES)
31
 
#       range. You'll want to vary this a bit to find the best
32
 
#       for your particular application's work load.
33
 
#
34
 
#   worker_class - The type of workers to use. The default
35
 
#       async class should handle most 'normal' types of work
36
 
#       loads. You'll want to read http://gunicorn/deployment.hml
37
 
#       for information on when you might want to choose one
38
 
#       of the other worker classes.
39
 
#
40
 
#       An string referring to a 'gunicorn.workers' entry point
41
 
#       or a MODULE:CLASS pair where CLASS is a subclass of
42
 
#       gunicorn.workers.base.Worker. The default provided values
43
 
#       are:
44
 
#
45
 
#           egg:gunicorn#sync
46
 
#           egg:gunicorn#eventlet   - Requires eventlet >= 0.9.7
47
 
#           egg:gunicorn#gevent     - Requires gevent >= 0.12.2 (?)
48
 
#           egg:gunicorn#tornado    - Requires tornado >= 0.2
49
 
#
50
 
#   worker_connections - For the eventlet and gevent worker classes
51
 
#       this limits the maximum number of simultaneous clients that
52
 
#       a single process can handle.
53
 
#
54
 
#       A positive integer generally set to around 1000.
55
 
#
56
 
#   timeout - If a worker does not notify the master process in this
57
 
#       number of seconds it is killed and a new worker is spawned
58
 
#       to replace it.
59
 
#
60
 
#       Generally set to thirty seconds. Only set this noticeably
61
 
#       higher if you're sure of the repercussions for sync workers.
62
 
#       For the non sync workers it just means that the worker
63
 
#       process is still communicating and is not tied to the length
64
 
#       of time required to handle a single request.
65
 
#
66
 
#   keepalive - The number of seconds to wait for the next request
67
 
#       on a Keep-Alive HTTP connection.
68
 
#
69
 
#       A positive integer. Generally set in the 1-5 seconds range.
70
 
#
71
 
 
72
 
workers = 1
73
 
worker_class = 'egg:gunicorn#sync'
74
 
worker_connections = 1000
75
 
timeout = 30
76
 
keepalive = 2
77
 
 
78
 
#
79
 
# Debugging
80
 
#
81
 
#   debug - Turn on debugging in the server. This limits the number of
82
 
#       worker processes to 1 and changes some error handling that's
83
 
#       sent to clients.
84
 
#
85
 
#       True or False
86
 
#
87
 
#   spew - Install a trace function that spews every line of Python
88
 
#       that is executed when running the server. This is the
89
 
#       nuclear option.
90
 
#
91
 
#       True or False
92
 
#
93
 
 
94
 
debug = False
95
 
spew = False
96
 
 
97
 
#
98
 
# Server mechanics
99
 
#
100
 
#   daemon - Detach the main Gunicorn process from the controlling
101
 
#       terminal with a standard fork/fork sequence.
102
 
#
103
 
#       True or False
104
 
#
105
 
#   pidfile - The path to a pid file to write
106
 
#
107
 
#       A path string or None to not write a pid file.
108
 
#
109
 
#   user - Switch worker processes to run as this user.
110
 
#
111
 
#       A valid user id (as an integer) or the name of a user that
112
 
#       can be retrieved with a call to pwd.getpwnam(value) or None
113
 
#       to not change the worker process user.
114
 
#
115
 
#   group - Switch worker process to run as this group.
116
 
#
117
 
#       A valid group id (as an integer) or the name of a user that
118
 
#       can be retrieved with a call to pwd.getgrnam(value) or None
119
 
#       to change the worker processes group.
120
 
#
121
 
#   umask - A mask for file permissions written by Gunicorn. Note that
122
 
#       this affects unix socket permissions.
123
 
#
124
 
#       A valid value for the os.umask(mode) call or a string
125
 
#       compatible with int(value, 0) (0 means Python guesses
126
 
#       the base, so values like "0", "0xFF", "0022" are valid
127
 
#       for decimal, hex, and octal representations)
128
 
#
129
 
#   tmp_upload_dir - A directory to store temporary request data when
130
 
#       requests are read. This will most likely be disappearing soon.
131
 
#
132
 
#       A path to a directory where the process owner can write. Or
133
 
#       None to signal that Python should choose one on its own.
134
 
#
135
 
 
136
 
daemon = False
137
 
pidfile = None
138
 
umask = 0
139
 
user = None
140
 
group = None
141
 
tmp_upload_dir = None
142
 
 
143
 
#
144
 
#   Logging
145
 
#
146
 
#   logfile - The path to a log file to write to.
147
 
#   
148
 
#       A path string. "-" means log to stdout.
149
 
#
150
 
#   loglevel - The granularity of log output
151
 
#
152
 
#       A string of "debug", "info", "warning", "error", "critical"
153
 
#
154
 
 
155
 
logfile = '-'
156
 
loglevel = 'info'
157
 
 
158
 
#
159
 
# Process naming
160
 
#
161
 
#   proc_name - A base to use with setproctitle to change the way
162
 
#       that Gunicorn processes are reported in the system process
163
 
#       table. This affects things like 'ps' and 'top'. If you're
164
 
#       going to be running more than one instance of Gunicorn you'll
165
 
#       probably want to set a name to tell them apart. This requires
166
 
#       that you install the setproctitle module.
167
 
#
168
 
#       A string or None to choose a default of something like 'gunicorn'.
169
 
#
170
 
 
171
 
proc_name = None
172
 
 
173
 
#
174
 
# Server hooks
175
 
#
176
 
#   after_fork - Called just after a worker has been forked.
177
 
#
178
 
#       A callable that takes a server and worker instance
179
 
#       as arguments.
180
 
#
181
 
#   before_fork - Called just prior to forking the worker subprocess.
182
 
#
183
 
#       A callable that accepts the same arguments as after_fork
184
 
#
185
 
#   before_exec - Called just prior to forking off a secondary
186
 
#       master process during things like config reloading.
187
 
#
188
 
#       A callable that takes a server instance as the sole argument.
189
 
#
190
 
 
191
 
def after_fork(server, worker):
192
 
    server.log.info("Worker spawned (pid: %s)" % worker.pid)
193
 
 
194
 
def before_fork(server, worker):
195
 
    pass
196
 
 
197
 
def before_exec(server):
198
 
    server.log.info("Forked child, re-executing.")