Download scripts/stop-dev.js from Woodiee/MindRAG: direct link, hf CLI and curl.
- Browser
- Download file 851 Bytes
-
https://huggingface.co/spaces/Woodiee/MindRAG/resolve/main/scripts/stop-dev.js
- Command line
-
hf download hf://spaces/Woodiee/MindRAG/scripts/stop-dev.js
-
curl -L -o stop-dev.js https://huggingface.co/spaces/Woodiee/MindRAG/resolve/main/scripts/stop-dev.js
851 Bytes
| const { execSync } = require("child_process"); | |
| const PORTS = [3000, 8000]; | |
| function killPortWindows(port) { | |
| try { | |
| const output = execSync(`netstat -ano | findstr :${port}`, { encoding: "utf8" }); | |
| const pids = new Set(); | |
| for (const line of output.split("\n")) { | |
| const parts = line.trim().split(/\s+/); | |
| if (parts.length >= 5 && parts[1]?.endsWith(`:${port}`) && parts[3] === "LISTENING") { | |
| pids.add(parts[4]); | |
| } | |
| } | |
| for (const pid of pids) { | |
| try { | |
| execSync(`taskkill /PID ${pid} /F`, { stdio: "ignore" }); | |
| console.log(`Stopped process ${pid} on port ${port}`); | |
| } catch { | |
| // Process may already be gone. | |
| } | |
| } | |
| } catch { | |
| // No process on this port. | |
| } | |
| } | |
| if (process.platform === "win32") { | |
| for (const port of PORTS) { | |
| killPortWindows(port); | |
| } | |
| } | |