Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for spaces in the galaxy root path, fix the galaxy entrypoint #87

Merged
merged 2 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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