mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Allow configuration of Galaxy via environment variables.
Allow overriding config defaults (those not specified in the configuration file) with GALAXY_CONFIG_<config-name> and allow overriding actual configured values with GALAXY_CONFIG_OVERRIDE_<config-name>. Here config-name is the actual value in galaxy.ini but in upper case.
This commit is contained in:
@@ -20,6 +20,9 @@ from galaxy import eggs
|
||||
|
||||
log = logging.getLogger( __name__ )
|
||||
|
||||
CONFIG_DEFAULT_PREFIX = "GALAXY_CONFIG_"
|
||||
CONFIG_OVERRIDE_PREFIX = "GALAXY_CONFIG_OVERRIDE_"
|
||||
|
||||
|
||||
def resolve_path( path, root ):
|
||||
"""If 'path' is relative make absolute by prepending 'root'"""
|
||||
@@ -36,6 +39,15 @@ class Configuration( object ):
|
||||
deprecated_options = ( 'database_file', )
|
||||
|
||||
def __init__( self, **kwargs ):
|
||||
for key in os.environ:
|
||||
if key.startswith( CONFIG_OVERRIDE_PREFIX ):
|
||||
config_key = key[ len( CONFIG_OVERRIDE_PREFIX ): ].lower()
|
||||
kwargs[ config_key ] = os.environ[ key ]
|
||||
elif key.startswith( CONFIG_DEFAULT_PREFIX ):
|
||||
config_key = key[ len( CONFIG_DEFAULT_PREFIX ): ].lower()
|
||||
if config_key not in kwargs:
|
||||
kwargs[ config_key ] = os.environ[ key ]
|
||||
|
||||
self.config_dict = kwargs
|
||||
self.root = kwargs.get( 'root_dir', '.' )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user