summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornestorluiscamachopaz <nestorluiscamachopaz@gmail.com>2026-06-01 17:26:22 -0400
committerDrew Ritter <drew@primeradiant.com>2026-06-16 10:09:44 -0700
commit48696e651946d762fb3a750f2ffc510dcd6777d6 (patch)
tree1af69ac621dcf377e1e2e566d4be9ae89836a001
parent4e3707fbbe648b5599c0b65080f053bfca7552a1 (diff)
fix: foreground mode saves node PID and clears OWNER_PID on Windows/MSYS2
Verified on real Windows Git Bash: lifecycle test passed 12/12, manual start/stop released the port, and no brainstorm node processes remained.
-rwxr-xr-xskills/brainstorming/scripts/start-server.sh17
1 files changed, 15 insertions, 2 deletions
diff --git a/skills/brainstorming/scripts/start-server.sh b/skills/brainstorming/scripts/start-server.sh
index 9ef6dcb..5ef391b 100755
--- a/skills/brainstorming/scripts/start-server.sh
+++ b/skills/brainstorming/scripts/start-server.sh
@@ -107,10 +107,23 @@ if [[ -z "$OWNER_PID" || "$OWNER_PID" == "1" ]]; then
OWNER_PID="$PPID"
fi
+# Windows/MSYS2: Node.js cannot see POSIX PIDs from the MSYS2 namespace.
+# Passing a PID node cannot verify causes server to log owner-pid-invalid
+# and self-terminate at the 60-second lifecycle check. Clear it so the
+# watchdog is disabled and the idle timeout becomes the only shutdown trigger.
+case "${OSTYPE:-}" in
+ msys*|cygwin*|mingw*) OWNER_PID="" ;;
+esac
+if [[ -n "${MSYSTEM:-}" ]]; then
+ OWNER_PID=""
+fi
+
# Foreground mode for environments that reap detached/background processes.
if [[ "$FOREGROUND" == "true" ]]; then
- echo "$$" > "$PID_FILE"
- env BRAINSTORM_DIR="$SESSION_DIR" BRAINSTORM_HOST="$BIND_HOST" BRAINSTORM_URL_HOST="$URL_HOST" BRAINSTORM_OWNER_PID="$OWNER_PID" node server.cjs
+ env BRAINSTORM_DIR="$SESSION_DIR" BRAINSTORM_HOST="$BIND_HOST" BRAINSTORM_URL_HOST="$URL_HOST" BRAINSTORM_OWNER_PID="$OWNER_PID" node server.cjs &
+ SERVER_PID=$!
+ echo "$SERVER_PID" > "$PID_FILE"
+ wait "$SERVER_PID"
exit $?
fi