Skip to content

feat(daemon): add Windows (Git Bash) support to daemon manager - #45

Open
Firegoiste wants to merge 1 commit into
Wechat-ggGitHub:mainfrom
Firegoiste:feat/windows-daemon-support
Open

feat(daemon): add Windows (Git Bash) support to daemon manager#45
Firegoiste wants to merge 1 commit into
Wechat-ggGitHub:mainfrom
Firegoiste:feat/windows-daemon-support

Conversation

@Firegoiste

Copy link
Copy Markdown

What

Adds Windows (Git Bash) support to scripts/daemon.sh.

Why

The daemon manager only handled Darwin / Linux. On Windows under Git Bash, uname -s returns MINGW64_NT-..., so the script fell through to *) and exited with Error: Unsupported platform. That made npm run daemon -- start|stop|restart|status|logs unusable on Windows, even though the Node daemon itself (dist/main.js) already runs fine there.

How

A new MINGW*|MSYS*|CYGWIN* branch in the dispatcher, backed by win_* functions that launch the daemon fully detached via PowerShell Start-Process (stdout/stderr redirected to the existing log files). Three Windows-specific pitfalls handled along the way:

  1. EPIPE crash — a plain nohup node & inherits the parent bash's stdio; when that shell exits, the daemon dies with write EPIPE. Start-Process detaches cleanly.
  2. Pipe-handle deadlock — capturing the launcher's stdout via $(...) hangs forever, because the detached child inherits the pipe handle and bash never sees EOF. Instead PowerShell writes the child PID straight into the pidfile and the launcher's stdio is fully detached (</dev/null >/dev/null 2>&1).
  3. kill -0 blindness — MSYS kill -0 <pid> can't see native Windows PIDs (it only tracks processes it spawned). Liveness is checked with tasklist //FI "PID eq <pid>", and stop uses taskkill //T //F to also reap child processes.

Compatibility

macOS (launchd) and Linux (systemd / nohup) code paths are untouched — this is a pure addition (+147 lines, 0 deletions in the logic; header comment updated to mention Windows).

Testing

On Windows 11 + Git Bash, Node 24:

  • start → launches detached, writes correct PID, survives the parent shell exiting (no more EPIPE)
  • status → correctly reports Running/Not running via tasklist
  • stoptaskkill reaps the process and children
  • full stopstartstatus lifecycle verified; start is idempotent (detects an already-running daemon via the pidfile and exits early, no duplicate instance)

@Firegoiste Firegoiste closed this Jul 23, 2026
@Firegoiste
Firegoiste force-pushed the feat/windows-daemon-support branch from 6f236df to 5014307 Compare July 23, 2026 06:45
The daemon manager only handled Darwin/Linux; on Windows (MINGW/MSYS/CYGWIN
under Git Bash) it exited with "Unsupported platform", so `npm run daemon --
start/stop/status` were unusable there. Add a Windows branch that launches the
daemon fully detached via PowerShell Start-Process. macOS/Linux unchanged.
@Firegoiste Firegoiste reopened this Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant