From 03504b3c1a8974c6bfce7bfbbb4ec6cc57f7fe34 Mon Sep 17 00:00:00 2001 From: cabana8471 Date: Mon, 26 Jan 2026 22:26:24 +0100 Subject: [PATCH] fix: use port-based process killing for cross-platform safety Addresses reviewer feedback: 1. Windows Compatibility: Added Windows alternative using netstat/taskkill 2. Safer Process Killing: Changed from `pkill -f "node"` to port-based killing (`lsof -ti :$PORT`) to avoid killing unrelated Node processes like VS Code, Claude Code, or other development tools Co-Authored-By: Claude Opus 4.5 --- .claude/templates/initializer_prompt.template.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.claude/templates/initializer_prompt.template.md b/.claude/templates/initializer_prompt.template.md index d2ded79..ccf1f98 100644 --- a/.claude/templates/initializer_prompt.template.md +++ b/.claude/templates/initializer_prompt.template.md @@ -155,8 +155,11 @@ Steps: Steps: 1. Create unique test data via API (e.g., POST /api/items with name "RESTART_TEST_12345") 2. Verify data appears in API response (GET /api/items) -3. STOP the server completely: pkill -f "node" && sleep 5 -4. Verify server is stopped: pgrep -f "node" returns nothing +3. STOP the server completely (kill by port to avoid killing unrelated Node processes): + - Unix/macOS: lsof -ti :$PORT | xargs kill -9 2>/dev/null || true && sleep 5 + - Windows: FOR /F "tokens=5" %a IN ('netstat -aon ^| find ":$PORT"') DO taskkill /F /PID %a 2>nul + - Note: Replace $PORT with actual port (e.g., 3000) +4. Verify server is stopped: lsof -ti :$PORT returns nothing (or netstat on Windows) 5. RESTART the server: ./init.sh & sleep 15 6. Query API again: GET /api/items 7. Verify "RESTART_TEST_12345" still exists