From 5a5b87abc6a8f15cf5737dda886f76a2e4d503c8 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Wed, 2 Mar 2022 17:39:48 +0100 Subject: [PATCH 1/6] Support managing gx-it-proxy via gravity --- gravity/config_manager.py | 18 +++++++++++++- gravity/defaults.py | 3 +++ gravity/process_manager/supervisor_manager.py | 21 ++++++++++++++++ gravity/state.py | 8 +++++++ tests/test_process_manager.py | 24 +++++++++++++++++++ 5 files changed, 73 insertions(+), 1 deletion(-) diff --git a/gravity/config_manager.py b/gravity/config_manager.py index e6e1dbe..6ad9688 100644 --- a/gravity/config_manager.py +++ b/gravity/config_manager.py @@ -16,6 +16,9 @@ CELERY_DEFAULT_CONFIG, DEFAULT_INSTANCE_NAME, GUNICORN_DEFAULT_CONFIG, + GXIT_DEFAULT_IP, + GXIT_DEFAULT_PORT, + GXIT_DEFAULT_SESSIONS, ) from gravity.io import debug, error, exception, info, warn from gravity.state import ( @@ -85,6 +88,7 @@ def get_config(self, conf, defaults=None): "app_server": "gunicorn", "gunicorn": GUNICORN_DEFAULT_CONFIG, "celery": CELERY_DEFAULT_CONFIG, + "gx_it_proxy": {}, "handlers": {}, } if defaults is not None: @@ -109,6 +113,7 @@ def get_config(self, conf, defaults=None): config.attribs["gunicorn"] = gravity_config["gunicorn"] config.attribs["celery"] = gravity_config["celery"] config.attribs["handlers"] = gravity_config["handlers"] + config.attribs["gx_it_proxy"] = gravity_config["gx_it_proxy"] # Store gravity version, in case we need to convert old setting config.attribs['gravity_version'] = __version__ webapp_service_names = [] @@ -129,7 +134,6 @@ def get_config(self, conf, defaults=None): config.services.append(service_for_service_type("celery")(config_type=config.config_type)) config.services.append(service_for_service_type("celery-beat")(config_type=config.config_type)) # If this is a Galaxy config, parse job_conf.xml for any *static* standalone handlers - # Marius: Don't think that's gonna work if job config file not defined! # TODO: use galaxy config parsing ? # TODO: if not, need yaml job config parsing job_conf_xml = app_config.get("job_config_file", DEFAULT_JOB_CONFIG_FILE) @@ -149,6 +153,7 @@ def get_config(self, conf, defaults=None): # doesn't parse that part of the job config. See logic in lib/galaxy/web_stack/handlers.py _get_is_handler() to # see how this is determined. self.create_handler_services(gravity_config, config) + self.create_gxit_services(gravity_config, app_config, config) return config def create_handler_services(self, gravity_config, config): @@ -158,6 +163,17 @@ def create_handler_services(self, gravity_config, config): config.services.append( service_for_service_type("standalone")(config_type=config.config_type, service_name=service_name, server_pools=pools)) + def create_gxit_services(self, gravity_config, app_config, config): + if app_config.get("interactivetools_enable") and gravity_config["gx_it_proxy"].get("enable"): + # TODO: resolve against data_dir, or bring in galaxy-config ? + # CWD in supervisor template is galaxy_root, so this should work for simple cases as is + gxit_config = gravity_config['gx_it_proxy'] + gxit_config["sessions"] = app_config.get("interactivetools_map", GXIT_DEFAULT_SESSIONS) + gxit_config["ip"] = gxit_config.get("ip", GXIT_DEFAULT_IP) + gxit_config["port"] = gxit_config.get("port", GXIT_DEFAULT_PORT) + gxit_config["verbose"] = '--verbose' if gxit_config.get("verbose") else '' + config.services.append(service_for_service_type("gx-it-proxy")(config_type=config.config_type, gxit=gxit_config)) + @staticmethod def expand_handlers(gravity_config, config): handlers = gravity_config.get("handlers", {}) diff --git a/gravity/defaults.py b/gravity/defaults.py index 5c6ee24..229f6f4 100644 --- a/gravity/defaults.py +++ b/gravity/defaults.py @@ -14,3 +14,6 @@ "concurrency": 2, "extra_args": "" } +GXIT_DEFAULT_IP = "localhost" +GXIT_DEFAULT_PORT = 4002 +GXIT_DEFAULT_SESSIONS = "database/interactivetools_map.sqlite" diff --git a/gravity/process_manager/supervisor_manager.py b/gravity/process_manager/supervisor_manager.py index d3befbb..1608f80 100644 --- a/gravity/process_manager/supervisor_manager.py +++ b/gravity/process_manager/supervisor_manager.py @@ -116,6 +116,26 @@ {process_name_opt} """ + +SUPERVISORD_SERVICE_TEMPLATES["gx-it-proxy"] = """; +; This file is maintained by Galaxy - CHANGES WILL BE OVERWRITTEN +; + +[program:{program_name}] +command = {command} +directory = {galaxy_root} +umask = {galaxy_umask} +autostart = true +autorestart = true +startsecs = 10 +stopwaitsecs = 10 +numprocs = 1 +stdout_logfile = {log_file} +redirect_stderr = true +{process_name_opt} +""" + + SUPERVISORD_SERVICE_TEMPLATES["standalone"] = """; ; This file is maintained by Galaxy - CHANGES WILL BE OVERWRITTEN ; @@ -237,6 +257,7 @@ def __update_service(self, config_file, config, attribs, service, instance_conf_ "attach_to_pool_opt": attach_to_pool_opt, "gunicorn": attribs["gunicorn"], "celery": attribs["celery"], + "gx_it_proxy": attribs["gx_it_proxy"], "galaxy_umask": service.get("umask", "022"), "program_name": program_name, "process_name_opt": process_name_opt, diff --git a/gravity/state.py b/gravity/state.py index f2d80bf..992fbc1 100644 --- a/gravity/state.py +++ b/gravity/state.py @@ -81,6 +81,13 @@ class GalaxyCeleryBeatService(Service): command_template = "{virtualenv_bin}celery --app galaxy.celery beat --loglevel {celery[loglevel]}" +class GalaxyGxItProxyService(Service): + service_type = "gx-it-proxy" + service_name = "gx-it-proxy" + command_template = "{virtualenv_bin}npx gx-it-proxy --ip {gx_it_proxy[ip]} --port {gx_it_proxy[port]}" \ + " --sessions {gx_it_proxy[sessions]} {gx_it_proxy[verbose]}" + + class GalaxyStandaloneService(Service): service_type = "standalone" service_name = "standalone" @@ -164,5 +171,6 @@ def service_for_service_type(service_type): "unicornherder": GalaxyUnicornHerderService, "celery": GalaxyCeleryService, "celery-beat": GalaxyCeleryBeatService, + "gx-it-proxy": GalaxyGxItProxyService, "standalone": GalaxyStandaloneService, } diff --git a/tests/test_process_manager.py b/tests/test_process_manager.py index 39de9c3..77a310c 100644 --- a/tests/test_process_manager.py +++ b/tests/test_process_manager.py @@ -46,6 +46,19 @@ - job-handler.special """ +GXIT_CONFIG = """ +gravity: + gx_it_proxy: + enable: true + proxy_port: 4002 +galaxy: + interactivetools_enable: true + interactivetools_map: database/interactivetools_map.sqlite + galaxy_infrastructure_url: http://localhost:8080 + interactivetools_upstream_proxy: false + interactivetools_proxy_host: localhost:4002 +""" + def test_update(galaxy_yml, default_config_manager): default_config_manager.add([str(galaxy_yml)]) @@ -97,3 +110,14 @@ def test_static_handlers(default_config_manager, galaxy_yml, job_conf): handler1_config_path = instance_conf_dir / 'galaxy_standalone_handler1.conf' assert handler1_config_path.exists() assert 'galaxy.yml --server-name=handler1 --pid-file=' in handler1_config_path.open().read() + + +def test_gxit_handler(default_config_manager, galaxy_yml): + galaxy_yml.write(GXIT_CONFIG) + default_config_manager.add([str(galaxy_yml)]) + with process_manager.process_manager(state_dir=default_config_manager.state_dir) as pm: + pm.update() + instance_conf_dir = Path(default_config_manager.state_dir) / 'supervisor' / 'supervisord.conf.d' / '_default_.d' + gxit_config_path = instance_conf_dir / 'galaxy_gx-it-proxy_gx-it-proxy.conf' + assert gxit_config_path.exists() + assert 'npx gx-it-proxy --ip localhost --port 4002 --sessions database/interactivetools_map.sqlite' in gxit_config_path.read_text() From 66d271a6843a983e34511a120f5dc8c5f15b19af Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 3 Mar 2022 12:54:40 +0100 Subject: [PATCH 2/6] Run gx-it-proxy from github repo, extend tests --- gravity/state.py | 2 +- tests/conftest.py | 32 ++++++++++++++++++++++++++++++++ tests/test_operations.py | 25 +++++++++++++++++++++++++ tests/test_process_manager.py | 21 +++++---------------- 4 files changed, 63 insertions(+), 17 deletions(-) diff --git a/gravity/state.py b/gravity/state.py index 992fbc1..6181bfc 100644 --- a/gravity/state.py +++ b/gravity/state.py @@ -84,7 +84,7 @@ class GalaxyCeleryBeatService(Service): class GalaxyGxItProxyService(Service): service_type = "gx-it-proxy" service_name = "gx-it-proxy" - command_template = "{virtualenv_bin}npx gx-it-proxy --ip {gx_it_proxy[ip]} --port {gx_it_proxy[port]}" \ + command_template = "npm_config_yes=true {virtualenv_bin}npx github:galaxyproject/gx-it-proxy --ip {gx_it_proxy[ip]} --port {gx_it_proxy[port]}" \ " --sessions {gx_it_proxy[sessions]} {gx_it_proxy[verbose]}" diff --git a/tests/conftest.py b/tests/conftest.py index fb1b9a0..f11099d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,9 +7,26 @@ from pathlib import Path import pytest +import yaml from gravity import config_manager TEST_DIR = Path(os.path.dirname(__file__)) +GXIT_CONFIG = """ +gravity: + gunicorn: + bind: 'localhost:{gx_port}' + gx_it_proxy: + enable: true + port: {gxit_port} + verbose: true +galaxy: + conda_auto_init: false + interactivetools_enable: true + interactivetools_map: database/interactivetools_map.sqlite + galaxy_infrastructure_url: http://localhost:{gx_port} + interactivetools_upstream_proxy: false + interactivetools_proxy_host: localhost:{gxit_port} +""" @pytest.fixture(scope='session') @@ -77,6 +94,9 @@ def free_port(): return portnum +another_free_port = free_port + + @pytest.fixture() def startup_config(galaxy_virtualenv, free_port): return { @@ -91,6 +111,18 @@ def startup_config(galaxy_virtualenv, free_port): } +@pytest.fixture +def gxit_config(free_port, another_free_port): + config_yaml = GXIT_CONFIG.format(gxit_port=another_free_port, gx_port=free_port) + return yaml.safe_load(config_yaml) + + +@pytest.fixture +def gxit_startup_config(galaxy_virtualenv, gxit_config): + gxit_config['gravity']['virtualenv'] = galaxy_virtualenv + return gxit_config + + @pytest.fixture(scope="session") def galaxy_virtualenv(galaxy_root_dir): virtual_env_dir = str(TEST_DIR / "galaxy_venv") diff --git a/tests/test_operations.py b/tests/test_operations.py index eca1330..a5e727b 100644 --- a/tests/test_operations.py +++ b/tests/test_operations.py @@ -38,6 +38,17 @@ def wait_for_startup(state_dir, free_port, prefix="/"): return startup_logs +def wait_for_gxit_proxy(state_dir): + startup_logs = "" + with open(state_dir / "log" / 'gx-it-proxy.log') as fh: + for _ in range(STARTUP_TIMEOUT * 4): + startup_logs = fh.read() + if 'Listening' in startup_logs: + return True + time.sleep(0.25) + return startup_logs + + def start_instance(state_dir, free_port): runner = CliRunner() result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'start']) @@ -60,6 +71,20 @@ def test_cmd_start(state_dir, galaxy_yml, startup_config, free_port): assert "All processes stopped, supervisord will exit" in result.output +def test_cmd_start_with_gxit(state_dir, galaxy_yml, gxit_startup_config, free_port): + galaxy_yml.write(json.dumps(gxit_startup_config)) + runner = CliRunner() + result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'register', str(galaxy_yml)]) + assert result.exit_code == 0 + result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'update']) + assert result.exit_code == 0 + start_instance(state_dir, free_port) + result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'status']) + assert result.exit_code == 0 + startup_done = wait_for_gxit_proxy(state_dir) + assert startup_done is True, f"gx-it-proxy startup failed. gx-it-proxy startup logs:\n {startup_done}" + + def test_cmd_restart_with_update(state_dir, galaxy_yml, startup_config, free_port): galaxy_yml.write(json.dumps(startup_config)) runner = CliRunner() diff --git a/tests/test_process_manager.py b/tests/test_process_manager.py index 77a310c..65646c2 100644 --- a/tests/test_process_manager.py +++ b/tests/test_process_manager.py @@ -46,19 +46,6 @@ - job-handler.special """ -GXIT_CONFIG = """ -gravity: - gx_it_proxy: - enable: true - proxy_port: 4002 -galaxy: - interactivetools_enable: true - interactivetools_map: database/interactivetools_map.sqlite - galaxy_infrastructure_url: http://localhost:8080 - interactivetools_upstream_proxy: false - interactivetools_proxy_host: localhost:4002 -""" - def test_update(galaxy_yml, default_config_manager): default_config_manager.add([str(galaxy_yml)]) @@ -112,12 +99,14 @@ def test_static_handlers(default_config_manager, galaxy_yml, job_conf): assert 'galaxy.yml --server-name=handler1 --pid-file=' in handler1_config_path.open().read() -def test_gxit_handler(default_config_manager, galaxy_yml): - galaxy_yml.write(GXIT_CONFIG) +def test_gxit_handler(default_config_manager, galaxy_yml, gxit_config): + galaxy_yml.write(json.dumps(gxit_config)) default_config_manager.add([str(galaxy_yml)]) with process_manager.process_manager(state_dir=default_config_manager.state_dir) as pm: pm.update() instance_conf_dir = Path(default_config_manager.state_dir) / 'supervisor' / 'supervisord.conf.d' / '_default_.d' gxit_config_path = instance_conf_dir / 'galaxy_gx-it-proxy_gx-it-proxy.conf' assert gxit_config_path.exists() - assert 'npx gx-it-proxy --ip localhost --port 4002 --sessions database/interactivetools_map.sqlite' in gxit_config_path.read_text() + gxit_port = gxit_config["gravity"]["gx_it_proxy"]["port"] + sessions = "database/interactivetools_map.sqlite" + assert f'npx github:galaxyproject/gx-it-proxy --ip localhost --port {gxit_port} --sessions {sessions}' in gxit_config_path.read_text() From 2ff180620048aabab9c2098aaa73df0735ddd664 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 3 Mar 2022 12:55:06 +0100 Subject: [PATCH 3/6] Implement update --force flag Implements https://github.com/galaxyproject/gravity/issues/33 --- gravity/commands/cmd_update.py | 5 +++-- gravity/process_manager/supervisor_manager.py | 8 ++++---- tests/test_process_manager.py | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/gravity/commands/cmd_update.py b/gravity/commands/cmd_update.py index 1fb6e4e..720ea28 100644 --- a/gravity/commands/cmd_update.py +++ b/gravity/commands/cmd_update.py @@ -4,8 +4,9 @@ @click.command("update") +@click.option("--force", is_flag=True, help="Force rewriting of process config files") @click.pass_context -def cli(ctx): +def cli(ctx, force): """Update process manager from config changes.""" with process_manager.process_manager(state_dir=ctx.parent.state_dir, start_daemon=False) as pm: - pm.update() + pm.update(force) diff --git a/gravity/process_manager/supervisor_manager.py b/gravity/process_manager/supervisor_manager.py index 1608f80..9e07bdb 100644 --- a/gravity/process_manager/supervisor_manager.py +++ b/gravity/process_manager/supervisor_manager.py @@ -279,7 +279,7 @@ def __update_service(self, config_file, config, attribs, service, instance_conf_ with open(conf, "w") as out: out.write(template.format(**format_vars)) - def _process_config_changes(self, configs, meta_changes): + def _process_config_changes(self, configs, meta_changes, force=False): # remove the services of any configs which have been removed for config in meta_changes["remove_configs"].values(): instance_name = config["instance_name"] @@ -294,7 +294,7 @@ def _process_config_changes(self, configs, meta_changes): for config_file, config in configs.items(): instance_name = config["instance_name"] attribs = config["attribs"] - update_all_configs = False + update_all_configs = False or force # config attribs have changed (galaxy_root, virtualenv, etc.) if "update_attribs" in config: @@ -431,10 +431,10 @@ def shutdown(self): time.sleep(0.5) info("supervisord has terminated") - def update(self): + def update(self, force=False): """Add newly defined servers, remove any that are no longer present""" configs, meta_changes = self.config_manager.determine_config_changes() - self._process_config_changes(configs, meta_changes) + self._process_config_changes(configs, meta_changes, force) # only need to update if supervisord is running, otherwise changes will be picked up at next start if self.__supervisord_is_running(): self.supervisorctl("update") diff --git a/tests/test_process_manager.py b/tests/test_process_manager.py index 65646c2..b091396 100644 --- a/tests/test_process_manager.py +++ b/tests/test_process_manager.py @@ -55,6 +55,20 @@ def test_update(galaxy_yml, default_config_manager): pm.update() +def test_update_force(galaxy_yml, default_config_manager): + test_update(galaxy_yml, default_config_manager) + instance_conf_dir = Path(default_config_manager.state_dir) / 'supervisor' / 'supervisord.conf.d' / '_default_.d' + gunicorn_conf_path = instance_conf_dir / "galaxy_gunicorn_gunicorn.conf" + assert gunicorn_conf_path.exists() + update_time = gunicorn_conf_path.stat().st_mtime + with process_manager.process_manager(state_dir=default_config_manager.state_dir) as pm: + pm.update() + assert gunicorn_conf_path.stat().st_mtime == update_time + with process_manager.process_manager(state_dir=default_config_manager.state_dir) as pm: + pm.update(force=True) + assert gunicorn_conf_path.stat().st_mtime != update_time + + @pytest.mark.parametrize('job_conf', [[JOB_CONF_XML_DYNAMIC_HANDLERS]], indirect=True) def test_dynamic_handlers(default_config_manager, galaxy_yml, job_conf): galaxy_yml.write(DYNAMIC_HANDLER_CONFIG) From 88fa6ae03a64b409b4f9f1becc16fa056d83a888 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 3 Mar 2022 13:06:14 +0100 Subject: [PATCH 4/6] Print output if exit code is non-zero --- tests/test_operations.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/test_operations.py b/tests/test_operations.py index a5e727b..e97ff22 100644 --- a/tests/test_operations.py +++ b/tests/test_operations.py @@ -14,7 +14,7 @@ def test_cmd_register(state_dir, galaxy_yml): runner = CliRunner() result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'register', str(galaxy_yml)]) - assert result.exit_code == 0 + assert result.exit_code == 0, result.output assert 'Registered galaxy config:' in result.output @@ -22,7 +22,7 @@ def test_cmd_deregister(state_dir, galaxy_yml): test_cmd_register(state_dir, galaxy_yml) runner = CliRunner() result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'deregister', str(galaxy_yml)]) - assert result.exit_code == 0 + assert result.exit_code == 0, result.output assert 'Deregistered config:' in result.output @@ -53,7 +53,7 @@ def start_instance(state_dir, free_port): runner = CliRunner() result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'start']) assert re.search(r"gunicorn\s*STARTING", result.output) - assert result.exit_code == 0 + assert result.exit_code == 0, result.output startup_done = wait_for_startup(state_dir, free_port) assert startup_done is True, f"Startup failed. Application startup logs:\n {startup_done}" @@ -62,12 +62,12 @@ def test_cmd_start(state_dir, galaxy_yml, startup_config, free_port): galaxy_yml.write(json.dumps(startup_config)) runner = CliRunner() result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'register', str(galaxy_yml)]) - assert result.exit_code == 0 + assert result.exit_code == 0, result.output result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'update']) - assert result.exit_code == 0 + assert result.exit_code == 0, result.output start_instance(state_dir, free_port) result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'stop']) - assert result.exit_code == 0 + assert result.exit_code == 0, result.output assert "All processes stopped, supervisord will exit" in result.output @@ -75,12 +75,12 @@ def test_cmd_start_with_gxit(state_dir, galaxy_yml, gxit_startup_config, free_po galaxy_yml.write(json.dumps(gxit_startup_config)) runner = CliRunner() result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'register', str(galaxy_yml)]) - assert result.exit_code == 0 + assert result.exit_code == 0, result.output result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'update']) - assert result.exit_code == 0 + assert result.exit_code == 0, result.output start_instance(state_dir, free_port) result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'status']) - assert result.exit_code == 0 + assert result.exit_code == 0, result.output startup_done = wait_for_gxit_proxy(state_dir) assert startup_done is True, f"gx-it-proxy startup failed. gx-it-proxy startup logs:\n {startup_done}" @@ -89,16 +89,16 @@ def test_cmd_restart_with_update(state_dir, galaxy_yml, startup_config, free_por galaxy_yml.write(json.dumps(startup_config)) runner = CliRunner() result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'register', str(galaxy_yml)]) - assert result.exit_code == 0 + assert result.exit_code == 0, result.output result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'update']) - assert result.exit_code == 0 + assert result.exit_code == 0, result.output start_instance(state_dir, free_port) # change prefix prefix = '/galaxypf/' startup_config['galaxy']['galaxy_url_prefix'] = prefix galaxy_yml.write(json.dumps(startup_config)) result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'restart']) - assert result.exit_code == 0 + assert result.exit_code == 0, result.output startup_done = wait_for_startup(state_dir=state_dir, free_port=free_port, prefix=prefix) assert startup_done is True, f"Startup failed. Application startup logs:\n {startup_done}" @@ -107,7 +107,7 @@ def test_cmd_show(state_dir, galaxy_yml): test_cmd_register(state_dir, galaxy_yml) runner = CliRunner() result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'show', str(galaxy_yml)]) - assert result.exit_code == 0 + assert result.exit_code == 0, result.output details = safe_load(result.output) assert details['config_type'] == 'galaxy' @@ -122,7 +122,7 @@ def test_cmd_show_config_does_not_exist(state_dir, galaxy_yml): assert f'To register this config file run "galaxyctl register {str(galaxy_yml)}"' in result.output # register the sample file, but ask for galaxy.yml result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'register', str(galaxy_yml + '.sample')]) - assert result.exit_code == 0 + assert result.exit_code == 0, result.output result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'show', str(galaxy_yml)]) assert result.exit_code == 1 assert f"{str(galaxy_yml)} is not a registered config file." in result.output @@ -133,21 +133,21 @@ def test_cmd_show_config_does_not_exist(state_dir, galaxy_yml): def test_cmd_instances(state_dir, galaxy_yml): runner = CliRunner() result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'instances']) - assert result.exit_code == 0 + assert result.exit_code == 0, result.output assert not result.output test_cmd_register(state_dir, galaxy_yml) result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'instances']) - assert result.exit_code == 0 + assert result.exit_code == 0, result.output assert "_default_" in result.output def test_cmd_configs(state_dir, galaxy_yml): runner = CliRunner() result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'configs']) - assert result.exit_code == 0 + assert result.exit_code == 0, result.output assert 'No config files registered' in result.output test_cmd_register(state_dir, galaxy_yml) result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'configs']) - assert result.exit_code == 0 + assert result.exit_code == 0, result.output assert result.output.startswith("TYPE") assert str(galaxy_yml) in result.output From dc1c5204496a15a29fe6486323eaff2ecc7cf2ac Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 3 Mar 2022 13:15:52 +0100 Subject: [PATCH 5/6] Make gxit setup with old and new npx --- gravity/process_manager/supervisor_manager.py | 1 + gravity/state.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/gravity/process_manager/supervisor_manager.py b/gravity/process_manager/supervisor_manager.py index 9e07bdb..9ae69e8 100644 --- a/gravity/process_manager/supervisor_manager.py +++ b/gravity/process_manager/supervisor_manager.py @@ -129,6 +129,7 @@ autorestart = true startsecs = 10 stopwaitsecs = 10 +environment = npm_config_yes=true numprocs = 1 stdout_logfile = {log_file} redirect_stderr = true diff --git a/gravity/state.py b/gravity/state.py index 6181bfc..fae21e4 100644 --- a/gravity/state.py +++ b/gravity/state.py @@ -84,7 +84,7 @@ class GalaxyCeleryBeatService(Service): class GalaxyGxItProxyService(Service): service_type = "gx-it-proxy" service_name = "gx-it-proxy" - command_template = "npm_config_yes=true {virtualenv_bin}npx github:galaxyproject/gx-it-proxy --ip {gx_it_proxy[ip]} --port {gx_it_proxy[port]}" \ + command_template = "{virtualenv_bin}npx github:galaxyproject/gx-it-proxy --ip {gx_it_proxy[ip]} --port {gx_it_proxy[port]}" \ " --sessions {gx_it_proxy[sessions]} {gx_it_proxy[verbose]}" From d77004655909b44d0fc68ddb7766eefced7bf5d1 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 4 Mar 2022 11:39:34 +0100 Subject: [PATCH 6/6] Install gx-it-proxy from npm instead of github --- gravity/state.py | 2 +- tests/test_process_manager.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gravity/state.py b/gravity/state.py index fae21e4..992fbc1 100644 --- a/gravity/state.py +++ b/gravity/state.py @@ -84,7 +84,7 @@ class GalaxyCeleryBeatService(Service): class GalaxyGxItProxyService(Service): service_type = "gx-it-proxy" service_name = "gx-it-proxy" - command_template = "{virtualenv_bin}npx github:galaxyproject/gx-it-proxy --ip {gx_it_proxy[ip]} --port {gx_it_proxy[port]}" \ + command_template = "{virtualenv_bin}npx gx-it-proxy --ip {gx_it_proxy[ip]} --port {gx_it_proxy[port]}" \ " --sessions {gx_it_proxy[sessions]} {gx_it_proxy[verbose]}" diff --git a/tests/test_process_manager.py b/tests/test_process_manager.py index b091396..26d3a46 100644 --- a/tests/test_process_manager.py +++ b/tests/test_process_manager.py @@ -123,4 +123,4 @@ def test_gxit_handler(default_config_manager, galaxy_yml, gxit_config): assert gxit_config_path.exists() gxit_port = gxit_config["gravity"]["gx_it_proxy"]["port"] sessions = "database/interactivetools_map.sqlite" - assert f'npx github:galaxyproject/gx-it-proxy --ip localhost --port {gxit_port} --sessions {sessions}' in gxit_config_path.read_text() + assert f'npx gx-it-proxy --ip localhost --port {gxit_port} --sessions {sessions}' in gxit_config_path.read_text()