From 7ba16d90adaa0c5f2f8cba34025b267356944c5d Mon Sep 17 00:00:00 2001 From: John Chilton Date: Fri, 4 May 2012 00:12:43 -0500 Subject: [PATCH 1/2] Augment run.sh to search for the optional environment variable GALAXY_UNIVERSE_CONFIG_DIR. If this is set, before Galaxy is launched the directory specified by the environment variable is searched for ini config files. These files are merged into a single configuration structure and written back out as universe.ini. This should allow for a more modular configuration of Galaxy. The files are merged in lexiographic order and later files can override properties specified ealier on. If a consistent naming scheme is used this can be really useful: As an example, one might specify the files as such: 000_galaxy_defaults.ini 000_default_sqlite_config.ini 100_institution_specific.ini 500_job_runner.ini 500_webapp_0.ini 500_webapp_1.ini 500_instance_specific.ini 500_available_postgres.ini --- run.sh | 4 ++++ scripts/build_universe_config.py | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 scripts/build_universe_config.py diff --git a/run.sh b/run.sh index ca14ece28a7..b3baea9fe58 100644 --- a/run.sh +++ b/run.sh @@ -33,6 +33,10 @@ for sample in $SAMPLES; do fi done +if [ -n "$GALAXY_UNIVERSE_CONFIG_DIR" ]; then + python ./scripts/build_universe_config.py "$GALAXY_UNIVERSE_CONFIG_DIR" +fi + # explicitly attempt to fetch eggs before running FETCH_EGGS=1 for arg in "$@"; do diff --git a/scripts/build_universe_config.py b/scripts/build_universe_config.py new file mode 100644 index 00000000000..15171f36595 --- /dev/null +++ b/scripts/build_universe_config.py @@ -0,0 +1,26 @@ +from ConfigParser import ConfigParser +from os import listdir +from os.path import join +from re import match +from sys import argv + + +def merge(): + "Merges all .ini files in a specified directory into ./universe.ini" + if len(argv) < 2: + message = "%s: Must specify directory to merge configuration files from." % argv[0] + raise Exception(message) + conf_directory = argv[1] + conf_files = [f for f in listdir(conf_directory) if match(r'.*\.ini', f)] + conf_files.sort() + + parser = ConfigParser() + for conf_file in conf_files: + parser.read([join(conf_directory, conf_file)]) + ## TODO: Expand enviroment variables here, that would + ## also make Galaxy much easier to configure. + + parser.write(open("universe.ini", 'w')) + +if __name__ == '__main__': + merge() From 55b451dcf47d36888ff94eb67d0905180633022a Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 24 May 2012 07:47:14 -0500 Subject: [PATCH 2/2] Fix a typo. --- scripts/build_universe_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build_universe_config.py b/scripts/build_universe_config.py index 15171f36595..dc7f8273969 100644 --- a/scripts/build_universe_config.py +++ b/scripts/build_universe_config.py @@ -20,7 +20,7 @@ def merge(): ## TODO: Expand enviroment variables here, that would ## also make Galaxy much easier to configure. - parser.write(open("universe.ini", 'w')) + parser.write(open("universe_wsgi.ini", 'w')) if __name__ == '__main__': merge()