2026-05-20 10:17:05 +08:00
|
|
|
@echo off
|
2026-05-23 09:32:32 +08:00
|
|
|
cd /d "%~dp0"
|
|
|
|
|
.venv\Scripts\python.exe -c "
|
|
|
|
|
import os, signal, subprocess
|
|
|
|
|
ports = (8000, 8001, 5173)
|
|
|
|
|
for port in ports:
|
|
|
|
|
try:
|
|
|
|
|
r = subprocess.run(['netstat', '-ano'], capture_output=True, text=True)
|
|
|
|
|
for line in r.stdout.splitlines():
|
|
|
|
|
if f':{port}' in line and 'LISTENING' in line:
|
|
|
|
|
pid = int(line.split()[-1])
|
|
|
|
|
print(f'Killing PID {pid} on port {port}')
|
|
|
|
|
os.kill(pid, signal.SIGTERM)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print(f'Port {port}: {e}')
|
|
|
|
|
print('Done')
|
|
|
|
|
"
|
2026-05-20 10:17:05 +08:00
|
|
|
pause
|