Add SERVER_SOFTWARE to the os.environ

Requested to allow a WSGI app to detect if its running in production
or development modes.
This commit is contained in:
Paul J. Davis 2010-09-06 15:23:30 -07:00
parent 995d060384
commit 3cc0e5df8a
3 changed files with 9 additions and 6 deletions

View File

@ -25,3 +25,4 @@ else:
version_info = (0, 11, "1%s" % minor_tag)
__version__ = ".".join(map(str, version_info))
SERVER_SOFTWARE = "gunicorn/%s" % __version__

View File

@ -18,7 +18,8 @@ from gunicorn.errors import HaltServer
from gunicorn.pidfile import Pidfile
from gunicorn.sock import create_socket
from gunicorn import util
from gunicorn import __version__
from gunicorn import __version__, SERVER_SOFTWARE
class Arbiter(object):
"""
@ -52,7 +53,9 @@ class Arbiter(object):
def __init__(self, app):
self.log = logging.getLogger(__name__)
self.log.info("Starting gunicorn %s" % __version__)
os.environ["SERVER_SOFTWARE"] = SERVER_SOFTWARE
self.setup(app)
self.pidfile = None

View File

@ -9,10 +9,9 @@ import re
import sys
from urllib import unquote
from gunicorn import __version__
from gunicorn import SERVER_SOFTWARE
import gunicorn.util as util
SERVER_VERSION = "gunicorn/%s" % __version__
NORMALIZE_SPACE = re.compile(r'(?:\r\n)?[ \t]+')
log = logging.getLogger(__name__)
@ -28,7 +27,7 @@ def create(req, sock, client, server, cfg):
"wsgi.multiprocess": (cfg.workers > 1),
"wsgi.run_once": False,
"gunicorn.socket": sock,
"SERVER_SOFTWARE": SERVER_VERSION,
"SERVER_SOFTWARE": SERVER_SOFTWARE,
"REQUEST_METHOD": req.method,
"QUERY_STRING": req.query,
"RAW_URI": req.uri,
@ -112,7 +111,7 @@ class Response(object):
def __init__(self, req, sock):
self.req = req
self.sock = sock
self.version = SERVER_VERSION
self.version = SERVER_SOFTWARE
self.status = None
self.chunked = False
self.should_close = req.should_close()