diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.py index 46907592d1733..08a084e855f07 100644 --- a/hermes_cli/gateway.py +++ b/hermes_cli/gateway.py @@ -563,7 +563,7 @@ def _gateway_run_args_for_profile(profile: str) -> list[str]: args = [get_python_path(), "-m", "hermes_cli.main"] if profile != "default": args.extend(["--profile", profile]) - args.extend(["gateway", "run", "--replace"]) + args.extend(["gateway", "run"]) return args @@ -2155,7 +2155,7 @@ def generate_systemd_unit(system: bool = False, run_as_user: str | None = None) Type=simple User={username} Group={group_name} -ExecStart={python_path} -m hermes_cli.main{f" {profile_arg}" if profile_arg else ""} gateway run --replace +ExecStart={python_path} -m hermes_cli.main{f" {profile_arg}" if profile_arg else ""} gateway run WorkingDirectory={working_dir} Environment="HOME={home_dir}" Environment="USER={username}" @@ -2193,7 +2193,7 @@ def generate_systemd_unit(system: bool = False, run_as_user: str | None = None) [Service] Type=simple -ExecStart={python_path} -m hermes_cli.main{f" {profile_arg}" if profile_arg else ""} gateway run --replace +ExecStart={python_path} -m hermes_cli.main{f" {profile_arg}" if profile_arg else ""} gateway run WorkingDirectory={working_dir} Environment="PATH={sane_path}" Environment="VIRTUAL_ENV={venv_dir}" @@ -2781,7 +2781,6 @@ def generate_launchd_plist() -> str: prog_args.extend([ "gateway", "run", - "--replace", ]) prog_args_xml = "\n ".join(prog_args) diff --git a/tests/hermes_cli/test_gateway_service.py b/tests/hermes_cli/test_gateway_service.py index 6fb012ff80724..046ec527566e1 100644 --- a/tests/hermes_cli/test_gateway_service.py +++ b/tests/hermes_cli/test_gateway_service.py @@ -493,7 +493,10 @@ def fake_run(cmd, check=False, **kwargs): label = gateway_cli.get_launchd_label() domain = gateway_cli._launchd_domain() - assert "--replace" in plist_path.read_text(encoding="utf-8") + plist_text = plist_path.read_text(encoding="utf-8") + assert "gateway" in plist_text + assert "run" in plist_text + assert "--replace" not in plist_text assert calls[:2] == [ ["launchctl", "bootout", f"{domain}/{label}"], ["launchctl", "bootstrap", domain, str(plist_path)], @@ -1636,7 +1639,8 @@ def test_systemd_unit_includes_profile(self, tmp_path, monkeypatch): monkeypatch.setattr(gateway_cli, "get_hermes_home", lambda: profile_dir) unit = gateway_cli.generate_systemd_unit(system=False) assert "--profile mybot" in unit - assert "gateway run --replace" in unit + assert "gateway run" in unit + assert "--replace" not in unit def test_launchd_plist_includes_profile(self, tmp_path, monkeypatch): """generate_launchd_plist should include --profile in ProgramArguments for named profiles.""" @@ -1648,6 +1652,24 @@ def test_launchd_plist_includes_profile(self, tmp_path, monkeypatch): plist = gateway_cli.generate_launchd_plist() assert "--profile" in plist assert "mybot" in plist + assert "--replace" not in plist + + def test_gateway_run_args_for_profile_omit_replace(self, monkeypatch): + monkeypatch.setattr(gateway_cli, "get_python_path", lambda: "/venv/bin/python") + + default_args = gateway_cli._gateway_run_args_for_profile("default") + named_args = gateway_cli._gateway_run_args_for_profile("mybot") + + assert default_args == ["/venv/bin/python", "-m", "hermes_cli.main", "gateway", "run"] + assert named_args == [ + "/venv/bin/python", + "-m", + "hermes_cli.main", + "--profile", + "mybot", + "gateway", + "run", + ] def test_launchd_plist_path_uses_real_user_home_not_profile_home(self, tmp_path, monkeypatch): profile_dir = tmp_path / ".hermes" / "profiles" / "orcha"