Skip to content

Commit

Permalink
Rewrote the sample config file.
Browse files Browse the repository at this point in the history
Includes more information on each parameters and groups parameters
by area of interest.
  • Loading branch information
davisp committed May 7, 2010
1 parent d1d88a8 commit 49521b8
Showing 1 changed file with 197 additions and 20 deletions.
217 changes: 197 additions & 20 deletions examples/gunicorn.conf.py.sample
Original file line number Diff line number Diff line change
@@ -1,20 +1,197 @@
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")
# Sample Gunicorn configuration file.

#
# Server socket
#
# bind - The socket to bind.
#
# A string of the form: 'HOST', 'HOST:PORT', 'unix:PATH'.
# An IP is a valid HOST.
#
# backlog - The number of pending connections. 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.
#
# Must be a positive integer. Generally set in the 64-2048
# range.
#

bind = '127.0.0.1:8000'
backlog = 2048

#
# Worker processes
#
# workers - The number of worker processes that this server
# should keep alive for handling requests.
#
# 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.
#
# worker_class - The type of workers to use. The default
# async class should handle most 'normal' types of work
# loads. You'll want to read http://gunicorn/deployment.hml
# for information on when you might want to choose one
# of the other worker classes.
#
# An string referring to a 'gunicorn.workers' entry point
# or a MODULE:CLASS pair where CLASS is a subclass of
# gunicorn.workers.base.Worker. The default provided values
# are:
#
# egg:gunicorn#sync
# egg:gunicorn#eventlet - Requires eventlet >= 0.9.7
# egg:gunicorn#gevent - Requires gevent >= 0.12.2 (?)
# egg:gunicorn#tornado - Requires tornado >= 0.2
#
# worker_connections - For the eventlet and gevent worker classes
# this limits the maximum number of simultaneous clients that
# a single process can handle.
#
# A positive integer generally set to around 1000.
#
# timeout - If a worker does not notify the master process in this
# number of seconds it is killed and a new worker is spawned
# to replace it.
#
# 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.
#
# keepalive - The number of seconds to wait for the next request
# on a Keep-Alive HTTP connection.
#
# A positive integer. Generally set in the few seconds range.
#

workers = 1
worker_class = 'egg:gunicorn#sync'
worker_connections = 1000
timeout = 30
keepalive = 2

#
# Debugging
#
# debug - Turn on debugging in the server. This limits the number of
# worker processes to 1 and changes some error handling that's
# sent to clients.
#
# True or False
#
# spew - Install a trace function that spews every line of Python
# that is executed when running the server. This is the
# nuclear option.
#
# True or False
#

debug = False
spew = False

#
# Server mechanics
#
# daemon - Detach the main Gunicorn process from the controlling
# terminal with a standard fork/fork sequence.
#
# True or False
#
# pidfile - The path to a pid file to write
#
# A path string or None to not write a pid file.
#
# user - Switch worker processes to run as this user.
#
# 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.
#
# group - Switch worker process to run as this group.
#
# 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 change the worker processes group.
#
# umask - A mask for file permissions written by Gunicorn. Only takes
# affect when the process has been daemonized.
#
# 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.
#
# tmp_upload_dir - A directory to store temporary request data when
# requests are read. This will most likely be disappearing soon.
#
# A path to a directory where the process owner can write. Or
# None to signal that Python should choose one on its own.
#

daemon = False
pidfile = None
umask = 0
user = None
group = None
tmp_upload_dir = None

#
# Logging
#
# logfile - The path to a log file to write to.
#
# A path string. "-" means log to stdout.
#
# loglevel - The granularity of log output
#
# A string of "debug", "info", "warning", "error", "critical"
#

logfile = '-'
loglevel = 'info'

#
# Process naming
#
# proc_name - A base to use with setproctitle to change the way
# that Gunicorn processes are reported in the system process
# table. This affects things like 'ps' and 'top'. 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.
#
# A string or None to choose a default of something like 'gunicorn'.
#

proc_name = None

#
# Server hooks
#
# after_fork - Called just after a worker has been forked.
#
# Something callable that takes two parameters.
#
# before_fork - Called just prior to forking the worker subprocess.
#
# Something callable that takes two parameters.
#
# before_exec - Called just prior to forking off a secondary
# master process during things like config reloading.
#
# Something callable that takes a single parameter.
#

def after_fork(server, worker):
server.log.info("Worker spawned (pid: %s)" % worker.pid)

def before_fork(server, worker):
pass

def before_exec(server):
server.log.info("Forked child, re-executing.")

0 comments on commit 49521b8

Please sign in to comment.