mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
fix issue #25.
This commit is contained in:
parent
368257a733
commit
d33c5b6c86
@ -21,6 +21,7 @@ Example gunicorn.conf.py
|
|||||||
user = None # Change process owner to user
|
user = None # Change process owner to user
|
||||||
group = None # Change process group to group
|
group = None # Change process group to group
|
||||||
proc_name = None # Change the process name
|
proc_name = None # Change the process name
|
||||||
|
tmp_upload_dir = None # Set path used to store temporary uploads
|
||||||
|
|
||||||
def after_fork(server, worker):
|
def after_fork(server, worker):
|
||||||
fmt = "worker=%s spawned pid=%s"
|
fmt = "worker=%s spawned pid=%s"
|
||||||
@ -74,3 +75,6 @@ umask:
|
|||||||
|
|
||||||
user:
|
user:
|
||||||
The user as which worker processes will by launched.
|
The user as which worker processes will by launched.
|
||||||
|
|
||||||
|
tmp_upload_dir:
|
||||||
|
Set the path used to store temporarily the body of the request.
|
||||||
@ -25,6 +25,7 @@ class Config(object):
|
|||||||
umask="0",
|
umask="0",
|
||||||
user=None,
|
user=None,
|
||||||
group=None,
|
group=None,
|
||||||
|
tmp_upload_dir=None,
|
||||||
|
|
||||||
after_fork=lambda server, worker: server.log.info(
|
after_fork=lambda server, worker: server.log.info(
|
||||||
"Worker spawned (pid: %s)" % worker.pid),
|
"Worker spawned (pid: %s)" % worker.pid),
|
||||||
|
|||||||
@ -36,8 +36,9 @@ class Request(object):
|
|||||||
"SERVER_SOFTWARE": "gunicorn/%s" % __version__
|
"SERVER_SOFTWARE": "gunicorn/%s" % __version__
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, socket, client_address, server_address, debug=False):
|
def __init__(self, socket, client_address, server_address, conf):
|
||||||
self.debug = debug
|
self.debug = conf['debug']
|
||||||
|
self.conf = conf
|
||||||
self.socket = socket
|
self.socket = socket
|
||||||
|
|
||||||
self.client_address = client_address
|
self.client_address = client_address
|
||||||
@ -73,7 +74,7 @@ class Request(object):
|
|||||||
if not self.parser.content_len and not self.parser.is_chunked:
|
if not self.parser.content_len and not self.parser.is_chunked:
|
||||||
wsgi_input = StringIO.StringIO()
|
wsgi_input = StringIO.StringIO()
|
||||||
else:
|
else:
|
||||||
wsgi_input = TeeInput(self.socket, self.parser, buf[i:])
|
wsgi_input = TeeInput(self.socket, self.parser, buf[i:], self.conf)
|
||||||
|
|
||||||
# This value should evaluate true if an equivalent application
|
# This value should evaluate true if an equivalent application
|
||||||
# object may be simultaneously invoked by another process, and
|
# object may be simultaneously invoked by another process, and
|
||||||
|
|||||||
@ -19,7 +19,8 @@ from gunicorn.util import MAX_BODY, CHUNK_SIZE, read_partial
|
|||||||
|
|
||||||
class TeeInput(object):
|
class TeeInput(object):
|
||||||
|
|
||||||
def __init__(self, socket, parser, buf):
|
def __init__(self, socket, parser, buf, conf):
|
||||||
|
self.conf = conf
|
||||||
self.buf = buf
|
self.buf = buf
|
||||||
self.parser = parser
|
self.parser = parser
|
||||||
self.socket = socket
|
self.socket = socket
|
||||||
@ -28,7 +29,8 @@ class TeeInput(object):
|
|||||||
if self._len and self._len < MAX_BODY:
|
if self._len and self._len < MAX_BODY:
|
||||||
self.tmp = StringIO.StringIO()
|
self.tmp = StringIO.StringIO()
|
||||||
else:
|
else:
|
||||||
self.tmp = tempfile.TemporaryFile()
|
self.tmp = tempfile.TemporaryFile(
|
||||||
|
dir=self.conf['tmp_upload_dir'])
|
||||||
|
|
||||||
if len(buf) > 0:
|
if len(buf) > 0:
|
||||||
chunk, self.buf = parser.filter_body(buf)
|
chunk, self.buf = parser.filter_body(buf)
|
||||||
|
|||||||
@ -143,7 +143,7 @@ class Worker(object):
|
|||||||
def handle(self, client, addr):
|
def handle(self, client, addr):
|
||||||
util.close_on_exec(client)
|
util.close_on_exec(client)
|
||||||
try:
|
try:
|
||||||
req = http.Request(client, addr, self.address, self.debug)
|
req = http.Request(client, addr, self.address, self.conf)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = self.app(req.read(), req.start_response)
|
response = self.app(req.read(), req.start_response)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user