Skip to content

Windows: nothing keeps the control daemon running (a per-user scheduled task beside launchd and systemd?) #184

Done

Description

@connorburgess

On Windows nothing keeps the control daemon running. control pair ends with

Daemon: no service manager for this platform yet; run `sessionpipe control run` yourself

so the daemon lives exactly as long as the terminal it was started in. Close it, log out or restart, and the machine shows offline on the board: starts and replies wait, and the self-update that runs in the daemon doesn't run either (#183 makes status say so). On a Mac and on Linux, pairing installs a launchd agent or a systemd user unit and none of this comes up.

What a normal (non-admin) user can create on Windows 11. I tried each option on a Windows 11 VM as a user without admin rights. Each test task ran cmd /c exit 0 and was deleted afterwards:

How Result
schtasks /Create /SC ONLOGON ERROR: Access is denied.
schtasks /Create /SC ONSTART ERROR: Access is denied.
Register-ScheduledTask with New-ScheduledTaskTrigger -AtLogOn -User <this user>, -LogonType Interactive -RunLevel Limited, no time limit, restart-on-failure settings, under a \sessionpipe\ folder registered; Start-ScheduledTask ran it, LastTaskResult 0
HKCU\Software\Microsoft\Windows\CurrentVersion\Run writable

So the natural third manager is a per-user scheduled task, made through the ScheduledTasks PowerShell module (plain schtasks refuses an at-logon trigger to a non-admin):

  • \sessionpipe\control, at logon for the current user, action <node.exe> <cli.js> control run (the same argv spec() builds for launchd/systemd), logging to daemon.log in the state dir;
  • installed where installService installs the others (control pair, connect), removed by control off;
  • an update's exit 75: Task Scheduler doesn't restart on an exit code, so the daemon would keep supervising itself as it does today when restartVia() finds no manager. That path already exists; it would just be the normal one on Windows.

Untested so far: whether node.exe from a logon task opens a console window, which would need a hidden launcher. The task can also be created without PowerShell, through schtasks /Create /XML with the same settings, but I haven't checked that as a non-admin. The HKCU Run key is the fallback if the scheduled task is unwanted: it has no admin needs and nothing to restart, but it gives no restart on failure and no per-task log.

The same mechanism could later back sessionpipe-gui service install, which says "a background service on Windows is not here yet".

Would you take a PR in this shape, with core's service module gaining a win32 manager beside launchd and systemd? Or would you rather it go another way?

Activity

  1. connorburgess commented on Oct 30, 2026

    @connorburgess
    ContributorAuthor
  2. kombuchapunk commented on Nov 19, 2026

    @kombuchapunk
    Collaborator

    Yes, I'd take a PR in that shape: a per-user scheduled task as a third manager in core's service module, next to launchd and systemd. One thing to check first on your VM: does node.exe started from a logon task open a console window? That decides whether we need a hidden launcher.

  3. connorburgess commented on Nov 22, 2026

    @connorburgess
    ContributorAuthor

    @kombuchapunk the PR for this is #317.

    On your question, whether node.exe started from a logon task opens a console window: yes. On the Windows 11 VM a task whose action is node.exe <script> put a visible Windows Terminal window titled C:\tools\node\node.exe on the desktop. The same script under conhost.exe --headless opened none, so the task runs Node that way, as sessionpipe-gui service install already does. No separate hidden launcher binary is needed.

    Two things in the PR differ from what I proposed above:

    • The task runs a small launcher script rather than control run itself. Task Scheduler gives an action no environment, keeps none of its output and restarts it on no exit code, so the launcher passes the pairing shell's PATH, appends to daemon.log, and starts the daemon again on 75 and after a failure.
    • restartVia() is not left as it is. With no manager it answers null, and doctor and update read null as "someone started it by hand". The launcher names itself by pid, as the supervisor does, and the daemon exits 75 for it.

    Not tested: a real logoff and logon, since the VM has no automatic logon. The trigger is the one sessionpipe-gui's task uses, and that task's last run on the VM is the second of the last interactive logon. The PR has the output for the rest.

    CI on a7237c9: all 13 jobs of run 44971534424 passed, which are Node 20, 22 and 24 on Ubuntu, macOS and Windows (the Ubuntu Node 22 one with the coverage thresholds), DCO sign-off, and the proto, spec and adapter gates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions