mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
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:
parent
53c4484bb8
commit
ec2ee0b127
@ -115,6 +115,8 @@ you can specify the Gunicorn server settings in your configuration file::
|
|||||||
use = egg:gunicorn#main
|
use = egg:gunicorn#main
|
||||||
host = 127.0.0.1
|
host = 127.0.0.1
|
||||||
port = 5000
|
port = 5000
|
||||||
|
# Uncomment the line below to use other advanced gunicorn settings
|
||||||
|
#config = %(here)/gunicorn.conf.py
|
||||||
|
|
||||||
And then as per usual::
|
And then as per usual::
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,8 @@ error_email_from = paste@localhost
|
|||||||
use = egg:gunicorn#main
|
use = egg:gunicorn#main
|
||||||
host = 127.0.0.1
|
host = 127.0.0.1
|
||||||
port = 5000
|
port = 5000
|
||||||
|
# Uncomment and replace with a file containing advanced gunicorn configuration
|
||||||
|
#config = %(here)/gunicorn.conf.py
|
||||||
|
|
||||||
[app:main]
|
[app:main]
|
||||||
use = egg:pylonstest
|
use = egg:pylonstest
|
||||||
|
|||||||
@ -16,7 +16,7 @@ from paste.deploy import loadapp, loadwsgi
|
|||||||
SERVER = loadwsgi.SERVER
|
SERVER = loadwsgi.SERVER
|
||||||
|
|
||||||
from gunicorn.app.base import Application
|
from gunicorn.app.base import Application
|
||||||
from gunicorn.config import Config
|
from gunicorn.config import Config, get_default_config_file
|
||||||
from gunicorn import util
|
from gunicorn import util
|
||||||
|
|
||||||
|
|
||||||
@ -126,17 +126,12 @@ class PasterServerApplication(PasterBaseApplication):
|
|||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def load_config(self):
|
if cfg.get("config"):
|
||||||
if not hasattr(self, "cfgfname"):
|
self.load_config_from_file(cfg["config"])
|
||||||
return
|
else:
|
||||||
|
default_config = get_defalult_config_file()
|
||||||
cfg = self.app_config()
|
if default_config is not None:
|
||||||
for k, v in cfg.items():
|
self.load_config_from_file(default_config)
|
||||||
try:
|
|
||||||
self.cfg.set(k.lower(), v)
|
|
||||||
except:
|
|
||||||
sys.stderr.write("Invalid value for %s: %s\n\n" % (k, v))
|
|
||||||
raise
|
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
if hasattr(self, "cfgfname"):
|
if hasattr(self, "cfgfname"):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user