Skip to content

Commit

Permalink
Merge pull request #87 from natefoo/space-path-fixes
Browse files Browse the repository at this point in the history
Fixes for spaces in the galaxy root path, fix the `galaxy` entrypoint
  • Loading branch information
natefoo authored Nov 18, 2022
2 parents b526905 + 18ebc28 commit 13ce6c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 7 additions & 3 deletions gravity/process_manager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _service_program_name(self, instance_name, service):
def _service_format_vars(self, config, service, pm_format_vars=None):
pm_format_vars = pm_format_vars or {}
virtualenv_dir = config.virtualenv
virtualenv_bin = f'{os.path.join(virtualenv_dir, "bin")}{os.path.sep}' if virtualenv_dir else ""
virtualenv_bin = shlex.quote(f'{os.path.join(virtualenv_dir, "bin")}{os.path.sep}') if virtualenv_dir else ""

format_vars = {
"config_type": service.config_type,
Expand All @@ -91,7 +91,7 @@ def _service_format_vars(self, config, service, pm_format_vars=None):
"galaxy_conf": config.galaxy_config_file,
"galaxy_root": config.galaxy_root,
"virtualenv_bin": virtualenv_bin,
"gravity_data_dir": config.gravity_data_dir,
"gravity_data_dir": shlex.quote(config.gravity_data_dir),
"app_config": config.app_config,
}

Expand All @@ -116,8 +116,12 @@ def _service_format_vars(self, config, service, pm_format_vars=None):
config_file = shlex.quote(config.gravity_config_file)
# is there a click way to do this?
galaxyctl = sys.argv[0]
if not galaxyctl.endswith("galaxyctl"):
if galaxyctl.endswith(f"{os.path.sep}galaxy"):
# handle when called using the `galaxy` entrypoint
galaxyctl += "ctl"
if not galaxyctl.endswith(f"{os.path.sep}galaxyctl"):
gravity.io.warn(f"Unable to determine galaxyctl command, sys.argv[0] is: {galaxyctl}")
galaxyctl = shlex.quote(galaxyctl)
instance_number_opt = ""
if service.count > 1:
instance_number_opt = f" --service-instance {pm_format_vars['instance_number']}"
Expand Down
5 changes: 1 addition & 4 deletions gravity/process_manager/systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def __update_service(self, config, service, systemd_service: SystemdService, for

# systemd-specific format vars
systemd_format_vars = {
"virtualenv_bin": f'{os.path.join(virtualenv_dir, "bin")}{os.path.sep}' if virtualenv_dir else "",
"virtualenv_bin": shlex.quote(f'{os.path.join(virtualenv_dir, "bin")}{os.path.sep}'),
"instance_number": "%i",
"systemd_user_group": "",
"systemd_exec_reload": exec_reload or "",
Expand All @@ -265,9 +265,6 @@ def __update_service(self, config, service, systemd_service: SystemdService, for

format_vars = self._service_format_vars(config, service, systemd_format_vars)

if not format_vars["command"].startswith("/"):
format_vars["command"] = f"{format_vars['virtualenv_bin']}{format_vars['command']}"

unit_file = systemd_service.unit_file_name
conf = os.path.join(self.__systemd_unit_dir, unit_file)
template = SYSTEMD_SERVICE_TEMPLATE
Expand Down

0 comments on commit 13ce6c5

Please sign in to comment.