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
@ -51,6 +51,34 @@ class DjangoApplicationCommand(Application):
|
||||
def __init__(self, options, admin_media_path):
|
||||
self.cfg = Config()
|
||||
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()):
|
||||
if k.lower() in self.cfg.settings and v is not None:
|
||||
@ -81,4 +109,4 @@ def run():
|
||||
applications.
|
||||
"""
|
||||
from gunicorn.app.djangoapp import DjangoApplication
|
||||
DjangoApplication("%prog [OPTIONS] [SETTINGS_PATH]").run()
|
||||
DjangoApplication("%prog [OPTIONS] [SETTINGS_PATH]").run()
|
||||
|
||||
@ -13,12 +13,12 @@ from django.conf import settings
|
||||
from django.utils import translation
|
||||
|
||||
from gunicorn.app.djangoapp import DjangoApplicationCommand
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('--adminmedia', dest='admin_media_path', default='',
|
||||
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]'),
|
||||
make_option('-k', '--worker-class', dest='worker_class',
|
||||
help="The type of request processing to use "+
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user