fix(s6): register profile gateways without auto-starting (#46266)
* fix(s6): prevent profile create from auto-starting gateway service When hermes profile create runs inside an s6 container, _maybe_register_gateway_service() calls register_profile_gateway() which creates the service directory and triggers s6-svscanctl -a. Previously the service always started immediately, causing profiles that share the main gateway's bot token (e.g. Kanban worker profiles) to fail with a token-lock conflict and persist gateway_state: running — becoming zombies that resurrect on every container restart. Wire the existing start_now parameter through the S6 implementation: when start_now=False, write a marker file (same pattern as container_boot.py _register_gateway_slot) so s6-supervise leaves the service stopped until the user explicitly runs hermes -p <profile> gateway start. 4 files, +61/-6, 4 new tests (all passing). * test(docker): wait for gateway running state before restart --------- Co-authored-by: liuhao1024 <sunsky.lau@gmail.com>
This commit is contained in:
@@ -586,6 +586,35 @@ def test_s6_register_creates_service_dir_and_triggers_scan(
|
||||
), f"s6-svscanctl -a not invoked; saw: {fake_subprocess_run}"
|
||||
|
||||
|
||||
def test_s6_register_start_now_false_writes_down_marker(
|
||||
s6_scandir, fake_subprocess_run,
|
||||
) -> None:
|
||||
"""When start_now=False, a `down` marker must be written so
|
||||
s6-supervise does not auto-start the service on rescan."""
|
||||
mgr = S6ServiceManager(scandir=s6_scandir)
|
||||
mgr.register_profile_gateway("coder", start_now=False)
|
||||
|
||||
svc_dir = s6_scandir / "gateway-coder"
|
||||
assert svc_dir.is_dir()
|
||||
assert (svc_dir / "down").is_file(), (
|
||||
"start_now=False must write a `down` marker file"
|
||||
)
|
||||
|
||||
|
||||
def test_s6_register_start_now_true_no_down_marker(
|
||||
s6_scandir, fake_subprocess_run,
|
||||
) -> None:
|
||||
"""When start_now=True (default), no `down` marker should exist."""
|
||||
mgr = S6ServiceManager(scandir=s6_scandir)
|
||||
mgr.register_profile_gateway("coder")
|
||||
|
||||
svc_dir = s6_scandir / "gateway-coder"
|
||||
assert svc_dir.is_dir()
|
||||
assert not (svc_dir / "down").exists(), (
|
||||
"start_now=True must NOT write a `down` marker file"
|
||||
)
|
||||
|
||||
|
||||
def test_s6_register_extra_env_is_quoted(s6_scandir, fake_subprocess_run) -> None:
|
||||
mgr = S6ServiceManager(scandir=s6_scandir)
|
||||
mgr.register_profile_gateway(
|
||||
|
||||
Reference in New Issue
Block a user