Support for python config file option in paster

It is now possible to specify a file with "config" as an application
configuration key in a paste deploy configuration file. This allows
paster applications to use the full range of gunicorn settings even
when using paste/pserve rather than gunicorn_paster.

Fixes #540.
This commit is contained in:
Randall Leeds 2013-08-05 21:59:00 -07:00
parent 53c4484bb8
commit ec2ee0b127
3 changed files with 11 additions and 12 deletions

View File

@ -115,6 +115,8 @@ you can specify the Gunicorn server settings in your configuration file::
use = egg:gunicorn#main
host = 127.0.0.1
port = 5000
# Uncomment the line below to use other advanced gunicorn settings
#config = %(here)/gunicorn.conf.py
And then as per usual::

View File

@ -14,6 +14,8 @@ error_email_from = paste@localhost
use = egg:gunicorn#main
host = 127.0.0.1
port = 5000
# Uncomment and replace with a file containing advanced gunicorn configuration
#config = %(here)/gunicorn.conf.py
[app:main]
use = egg:pylonstest

View File

@ -16,7 +16,7 @@ from paste.deploy import loadapp, loadwsgi
SERVER = loadwsgi.SERVER
from gunicorn.app.base import Application
from gunicorn.config import Config
from gunicorn.config import Config, get_default_config_file
from gunicorn import util
@ -126,17 +126,12 @@ class PasterServerApplication(PasterBaseApplication):
sys.stderr.flush()
sys.exit(1)
def load_config(self):
if not hasattr(self, "cfgfname"):
return
cfg = self.app_config()
for k, v in cfg.items():
try:
self.cfg.set(k.lower(), v)
except:
sys.stderr.write("Invalid value for %s: %s\n\n" % (k, v))
raise
if cfg.get("config"):
self.load_config_from_file(cfg["config"])
else:
default_config = get_defalult_config_file()
if default_config is not None:
self.load_config_from_file(default_config)
def load(self):
if hasattr(self, "cfgfname"):