1
# Sample Gunicorn configuration file.
6
# bind - The socket to bind.
8
# A string of the form: 'HOST', 'HOST:PORT', 'unix:PATH'.
9
# An IP is a valid HOST.
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.
17
# Must be a positive integer. Generally set in the 64-2048
21
bind = '127.0.0.1:8000'
27
# workers - The number of worker processes that this server
28
# should keep alive for handling requests.
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.
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.
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
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
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.
54
# A positive integer generally set to around 1000.
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
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.
66
# keepalive - The number of seconds to wait for the next request
67
# on a Keep-Alive HTTP connection.
69
# A positive integer. Generally set in the 1-5 seconds range.
73
worker_class = 'egg:gunicorn#sync'
74
worker_connections = 1000
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
87
# spew - Install a trace function that spews every line of Python
88
# that is executed when running the server. This is the
100
# daemon - Detach the main Gunicorn process from the controlling
101
# terminal with a standard fork/fork sequence.
105
# pidfile - The path to a pid file to write
107
# A path string or None to not write a pid file.
109
# user - Switch worker processes to run as this user.
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.
115
# group - Switch worker process to run as this group.
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.
121
# umask - A mask for file permissions written by Gunicorn. Note that
122
# this affects unix socket permissions.
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)
129
# tmp_upload_dir - A directory to store temporary request data when
130
# requests are read. This will most likely be disappearing soon.
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.
141
tmp_upload_dir = None
146
# logfile - The path to a log file to write to.
148
# A path string. "-" means log to stdout.
150
# loglevel - The granularity of log output
152
# A string of "debug", "info", "warning", "error", "critical"
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.
168
# A string or None to choose a default of something like 'gunicorn'.
176
# after_fork - Called just after a worker has been forked.
178
# A callable that takes a server and worker instance
181
# before_fork - Called just prior to forking the worker subprocess.
183
# A callable that accepts the same arguments as after_fork
185
# before_exec - Called just prior to forking off a secondary
186
# master process during things like config reloading.
188
# A callable that takes a server instance as the sole argument.
191
def after_fork(server, worker):
192
server.log.info("Worker spawned (pid: %s)" % worker.pid)
194
def before_fork(server, worker):
197
def before_exec(server):
198
server.log.info("Forked child, re-executing.")