Allow Lemur "start" to use the global config. (#596)

* allowing our runserver to use the config specified by -c

* Maintaining config for gunicorn
This commit is contained in:
kevgliss 2016-12-14 13:23:50 -08:00 committed by GitHub
parent 71ddbb409c
commit 02991c70a9
3 changed files with 10 additions and 5 deletions

View File

@ -60,11 +60,14 @@ class InstanceManager(object):
results.append(cls()) results.append(cls())
else: else:
results.append(cls) results.append(cls)
except InvalidConfiguration as e: except InvalidConfiguration as e:
current_app.logger.warning("Plugin '{0}' may not work correctly. {1}".format(class_name, e)) current_app.logger.warning("Plugin '{0}' may not work correctly. {1}".format(class_name, e))
except Exception as e: except Exception as e:
current_app.logger.exception("Unable to import {0}. Reason: {1}".format(cls_path, e)) current_app.logger.exception("Unable to import {0}. Reason: {1}".format(cls_path, e))
continue continue
self.cache = results self.cache = results
return results return results

View File

@ -92,6 +92,7 @@ def configure_app(app, config=None):
""" """
# respect the config first # respect the config first
if config and config != 'None': if config and config != 'None':
app.config['CONFIG_PATH'] = config
app.config.from_object(from_file(config)) app.config.from_object(from_file(config))
else: else:
try: try:
@ -103,6 +104,9 @@ def configure_app(app, config=None):
else: else:
app.config.from_object(from_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'default.conf.py'))) app.config.from_object(from_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'default.conf.py')))
# we don't use this
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
def configure_extensions(app): def configure_extensions(app):
""" """

View File

@ -119,7 +119,6 @@ LOG_FILE = "lemur.log"
# modify this if you are not using a local database # modify this if you are not using a local database
SQLALCHEMY_DATABASE_URI = 'postgresql://lemur:lemur@localhost:5432/lemur' SQLALCHEMY_DATABASE_URI = 'postgresql://lemur:lemur@localhost:5432/lemur'
# AWS # AWS
#LEMUR_INSTANCE_PROFILE = 'Lemur' #LEMUR_INSTANCE_PROFILE = 'Lemur'
@ -372,11 +371,10 @@ class LemurServer(Command):
app = WSGIApplication() app = WSGIApplication()
# run startup tasks on an app like object # run startup tasks on a app like object
pre_app = create_app(kwargs.get('config')) validate_conf(current_app, REQUIRED_VARIABLES)
validate_conf(pre_app, REQUIRED_VARIABLES)
app.app_uri = 'lemur:create_app(config="{0}")'.format(kwargs.get('config')) app.app_uri = 'lemur:create_app(config="{0}")'.format(current_app.config.get('CONFIG_PATH'))
return app.run() return app.run()