mirror of https://github.com/snachodog/mybuddy.git
130 lines
3.8 KiB
Python
130 lines
3.8 KiB
Python
# Server mechanics
|
|
bind = '0.0.0.0:8000'
|
|
backlog = 2048
|
|
daemon = False
|
|
pidfile = None
|
|
umask = 0
|
|
user = None
|
|
group = None
|
|
tmp_upload_dir = None
|
|
proc_name = None
|
|
|
|
# Logging
|
|
errorlog = '-'
|
|
loglevel = 'info'
|
|
accesslog = '-'
|
|
access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"'
|
|
|
|
#
|
|
# 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
|
|
# sync class should handle most 'normal' types of work
|
|
# loads. You'll want to read
|
|
# http://docs.gunicorn.org/en/latest/design.html#choosing-a-worker-type
|
|
# 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 python path to 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 1-5 seconds range.
|
|
#
|
|
|
|
workers = 1
|
|
worker_class = 'sync'
|
|
worker_connections = 1000
|
|
timeout = 30
|
|
keepalive = 2
|
|
|
|
spew = False
|
|
|
|
#
|
|
# Server hooks
|
|
#
|
|
# post_fork - Called just after a worker has been forked.
|
|
#
|
|
# A callable that takes a server and worker instance
|
|
# as arguments.
|
|
#
|
|
# pre_fork - Called just prior to forking the worker subprocess.
|
|
#
|
|
# A callable that accepts the same arguments as after_fork
|
|
#
|
|
# pre_exec - Called just prior to forking off a secondary
|
|
# master process during things like config reloading.
|
|
#
|
|
# A callable that takes a server instance as the sole argument.
|
|
#
|
|
|
|
|
|
def post_fork(server, worker):
|
|
server.log.info("Worker spawned (pid: %s)", worker.pid)
|
|
|
|
|
|
def pre_fork(server, worker):
|
|
pass
|
|
|
|
|
|
def pre_exec(server):
|
|
server.log.info("Forked child, re-executing.")
|
|
|
|
|
|
def when_ready(server):
|
|
server.log.info("Server is ready. Spawning workers")
|
|
|
|
|
|
def worker_int(worker):
|
|
worker.log.info("worker received INT or QUIT signal")
|
|
|
|
# get traceback info
|
|
import threading, sys, traceback
|
|
id2name = dict([(th.ident, th.name) for th in threading.enumerate()])
|
|
code = []
|
|
for threadId, stack in sys._current_frames().items():
|
|
code.append("\n# Thread: %s(%d)" % (id2name.get(threadId,""),
|
|
threadId))
|
|
for filename, lineno, name, line in traceback.extract_stack(stack):
|
|
code.append('File: "%s", line %d, in %s' % (filename,
|
|
lineno, name))
|
|
if line:
|
|
code.append(" %s" % (line.strip()))
|
|
worker.log.debug("\n".join(code))
|
|
|
|
|
|
def worker_abort(worker):
|
|
worker.log.info("worker received SIGABRT signal")
|