mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
fix issue #84. thanks!
This commit is contained in:
parent
ea77f56449
commit
e625188196
@ -52,6 +52,34 @@ class DjangoApplicationCommand(Application):
|
|||||||
self.cfg = Config()
|
self.cfg = Config()
|
||||||
self.callable = None
|
self.callable = None
|
||||||
|
|
||||||
|
# Load up the config file if its found.
|
||||||
|
|
||||||
|
config_file = options.get("config") or ""
|
||||||
|
if config_file and os.path.exists(config_file):
|
||||||
|
cfg = {
|
||||||
|
"__builtins__": __builtins__,
|
||||||
|
"__name__": "__config__",
|
||||||
|
"__file__": config_file,
|
||||||
|
"__doc__": None,
|
||||||
|
"__package__": None
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
execfile(config_file, cfg, cfg)
|
||||||
|
except Exception, e:
|
||||||
|
print "Failed to read config file: %s" % config_file
|
||||||
|
traceback.print_exc()
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
for k, v in list(cfg.items()):
|
||||||
|
# Ignore unknown names
|
||||||
|
if k not in self.cfg.settings:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
self.cfg.set(k.lower(), v)
|
||||||
|
except:
|
||||||
|
sys.stderr.write("Invalid value for %s: %s\n\n" % (k, v))
|
||||||
|
raise
|
||||||
|
|
||||||
for k, v in list(options.items()):
|
for k, v in list(options.items()):
|
||||||
if k.lower() in self.cfg.settings and v is not None:
|
if k.lower() in self.cfg.settings and v is not None:
|
||||||
self.cfg.set(k.lower(), v)
|
self.cfg.set(k.lower(), v)
|
||||||
|
|||||||
@ -18,7 +18,7 @@ class Command(BaseCommand):
|
|||||||
option_list = BaseCommand.option_list + (
|
option_list = BaseCommand.option_list + (
|
||||||
make_option('--adminmedia', dest='admin_media_path', default='',
|
make_option('--adminmedia', dest='admin_media_path', default='',
|
||||||
help='Specifies the directory from which to serve admin media.'),
|
help='Specifies the directory from which to serve admin media.'),
|
||||||
make_option('-c', '--config', dest='gconfig', type='string',
|
make_option('-c', '--config', dest='config', type='string',
|
||||||
help='Gunicorn Config file. [%default]'),
|
help='Gunicorn Config file. [%default]'),
|
||||||
make_option('-k', '--worker-class', dest='worker_class',
|
make_option('-k', '--worker-class', dest='worker_class',
|
||||||
help="The type of request processing to use "+
|
help="The type of request processing to use "+
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user