improve output if config can not be parsed
This commit is contained in:
parent
9e88f29126
commit
310343c81c
1 changed files with 16 additions and 6 deletions
|
@ -35,17 +35,27 @@ def get_version():
|
||||||
return u'%s' % rev
|
return u'%s' % rev
|
||||||
return u'unknown'
|
return u'unknown'
|
||||||
|
|
||||||
def load_config():
|
def load_config(init=False):
|
||||||
with open(settings.SITE_CONFIG) as f:
|
with open(settings.SITE_CONFIG) as f:
|
||||||
try:
|
try:
|
||||||
config = ox.jsonc.load(f)
|
config = ox.jsonc.load(f)
|
||||||
except:
|
except ValueError as e:
|
||||||
|
if init:
|
||||||
|
print("Failed to parse %s:\n" % settings.SITE_CONFIG)
|
||||||
|
print (e)
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
config = None
|
config = None
|
||||||
|
|
||||||
with open(settings.DEFAULT_CONFIG) as f:
|
with open(settings.DEFAULT_CONFIG) as f:
|
||||||
try:
|
try:
|
||||||
default = ox.jsonc.load(f)
|
default = ox.jsonc.load(f)
|
||||||
except:
|
except ValueError as e:
|
||||||
|
if init:
|
||||||
|
print("Failed to default config %s:\n" % settings.DEFAULT_CONFIG)
|
||||||
|
print (e)
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
default = None
|
default = None
|
||||||
|
|
||||||
if config:
|
if config:
|
||||||
|
@ -306,7 +316,7 @@ def update_geoip(force=False):
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
if not settings.RELOADER_RUNNING:
|
if not settings.RELOADER_RUNNING:
|
||||||
load_config()
|
load_config(True)
|
||||||
if settings.RELOAD_CONFIG:
|
if settings.RELOAD_CONFIG:
|
||||||
thread.start_new_thread(reloader_thread, ())
|
thread.start_new_thread(reloader_thread, ())
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue