summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/tests/test_cli_dispatch.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-04 03:58:16 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-04 03:58:16 +0200
commit220e6e701806213a576ce80fa655cd9cf4a51880 (patch)
tree04b1f059044f4e02d1e8cb6c4a6588982cf395c4 /packages/meshbay-node/tests/test_cli_dispatch.py
parent5098e6cb54173b27673f5761ce187d799ba36b30 (diff)
downloadmeshbay-220e6e701806213a576ce80fa655cd9cf4a51880.tar.gz
feat: Windows daemon lifecycle (W3) — Startup-folder autostart
The Linux node runs under `systemctl --user`. Windows has no per-user equivalent that works without elevation: `schtasks /create /sc ONLOGON` (even `/rl LIMITED /it`) fails with "Access is denied" for a non-admin user, because a logon trigger touches machine-wide scheduler state. So autostart is a `.vbs` in the per-user Startup folder instead: CreateObject("WScript.Shell").Run Chr(34) & "<exe>" & Chr(34), 0, False wscript runs it at every sign-in, hidden (0) and non-blocking. No admin, no console window, no new dependency. Verified end to end: the launcher brings the daemon up with no window and it answers its loopback API. node/platform.py autostart_install/remove/status — write / delete / detect the launcher autostart_run/end — start now (DETACHED|NO_WINDOW) / taskkill _node_exe — PATH, then next to sys.executable, then argv[0] node/daemon.py new `autostart install|remove|start|stop|status` verb reload (win32) -> POST /api/reload on the loopback API restart-daemon (win32) -> autostart_end + autostart_run reset (win32) -> also removes the launcher client/main.js, preload.js node:autostart handler + winAutostart* helpers (kept in step with platform.py) node:service-status (win32) probes the daemon; stop/restart/start use taskkill + a detached, windowless spawn Tests: 8 autostart cases in test_platform.py (mocked sys.platform, APPDATA pointed at tmp); `autostart status` added to the CLI dispatch sweep. Full meshbay-node suite green on Windows (784 passed / 34 skipped). Still open: no CTRL_CLOSE_EVENT handler, so a bare taskkill / window close does not run _shutdown() (SetConsoleCtrlHandler, follow-up). Service mode (pywin32/NSSM) stays Phase 2. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/tests/test_cli_dispatch.py')
-rw-r--r--packages/meshbay-node/tests/test_cli_dispatch.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/packages/meshbay-node/tests/test_cli_dispatch.py b/packages/meshbay-node/tests/test_cli_dispatch.py
index 76eb6d5..606e586 100644
--- a/packages/meshbay-node/tests/test_cli_dispatch.py
+++ b/packages/meshbay-node/tests/test_cli_dispatch.py
@@ -42,6 +42,7 @@ VERBS = [
["stun", "list"],
["reload"],
["restart-daemon"],
+ ["autostart", "status"],
]
@@ -141,7 +142,8 @@ def test_the_verb_list_here_matches_the_parser():
@pytest.mark.skipif(sys.platform == "win32",
- reason="systemd lifecycle; Windows path (schtasks) is W3, not built")
+ reason="systemd lifecycle; Windows uses the loopback API / "
+ "Startup-folder launcher, covered by test_platform.py")
@pytest.mark.parametrize("argv,verb", [
(["reload"], "reload"),
(["restart-daemon"], "restart"),
@@ -170,7 +172,8 @@ def test_lifecycle_commands_delegate_to_systemctl_user(
@pytest.mark.skipif(sys.platform == "win32",
- reason="systemd lifecycle; Windows path (schtasks) is W3, not built")
+ reason="systemd lifecycle; Windows uses the loopback API / "
+ "Startup-folder launcher, covered by test_platform.py")
@pytest.mark.parametrize("argv", [["reload"], ["restart-daemon"]])
def test_lifecycle_commands_report_systemctl_failure(
argv, stub_daemon, monkeypatch, capsys):