improve: comprehensive process cleanup in startup script

- Add -9 (force kill) flag to all pkill commands
- Kill Python backend processes explicitly
- Kill npm and node processes
- Use fuser to kill processes bound to ports 8000, 3001, 3002, 3003
- Add 1 second wait after cleanup
- Ensures absolutely clean state before restart
This commit is contained in:
2026-04-22 09:45:50 +03:00
parent 70a08ae1e9
commit 59565c9b8a

View File

@@ -17,11 +17,28 @@ fi
echo "🚀 Starting TFM aInventory Stack with Dual Proxy..."
# 1. Kill potentially hanging processes
echo "Sweep: Cleaning up old processes..."
pkill -f "uvicorn" || true
pkill -f "next-server" || true
pkill -f "local-ssl-proxy" || true
# 1. COMPREHENSIVE process cleanup - ensure absolute clean state
echo "Sweep: Comprehensive process cleanup..."
# Kill all known hanging processes
pkill -9 -f "uvicorn" 2>/dev/null || true
pkill -9 -f "next-server" 2>/dev/null || true
pkill -9 -f "local-ssl-proxy" 2>/dev/null || true
pkill -9 -f "python.*backend" 2>/dev/null || true
pkill -9 -f "python.*main:app" 2>/dev/null || true
pkill -9 -f "npm run dev" 2>/dev/null || true
pkill -9 -f "node.*next" 2>/dev/null || true
# Kill any remaining Python processes on port 8000 (backend)
fuser -k 8000/tcp 2>/dev/null || true
fuser -k 3001/tcp 2>/dev/null || true
fuser -k 3002/tcp 2>/dev/null || true
fuser -k 3003/tcp 2>/dev/null || true
# Extra wait to ensure processes are fully dead
sleep 1
echo "✅ Cleanup complete - all processes terminated"
# 2. Setup/Activate Virtual Environment
if [ ! -f ".venv/bin/activate" ]; then