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 <noreply@anthropic.com>
This commit is contained in:
cabana8471
2026-01-26 22:26:24 +01:00
parent d1233ad104
commit 03504b3c1a

View File

@@ -155,8 +155,11 @@ Steps:
Steps: Steps:
1. Create unique test data via API (e.g., POST /api/items with name "RESTART_TEST_12345") 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) 2. Verify data appears in API response (GET /api/items)
3. STOP the server completely: pkill -f "node" && sleep 5 3. STOP the server completely (kill by port to avoid killing unrelated Node processes):
4. Verify server is stopped: pgrep -f "node" returns nothing - 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 5. RESTART the server: ./init.sh & sleep 15
6. Query API again: GET /api/items 6. Query API again: GET /api/items
7. Verify "RESTART_TEST_12345" still exists 7. Verify "RESTART_TEST_12345" still exists