Prj2 / restart_server.ps1
iitmbs24f's picture
Upload 37 files
2f95553 verified
# Script to stop any server on port 8000 and start the correct one
# Usage: .\restart_server.ps1
Write-Host "IITM LLM Quiz Solver - Server Restart" -ForegroundColor Cyan
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host ""
# Find process using port 8000
Write-Host "Finding process using port 8000..." -ForegroundColor Yellow
$portInfo = netstat -ano | findstr :8000 | findstr LISTENING
if ($portInfo) {
$pid = ($portInfo -split '\s+')[-1]
Write-Host "Found process ID: $pid" -ForegroundColor Yellow
$process = Get-Process -Id $pid -ErrorAction SilentlyContinue
if ($process) {
Write-Host "Process: $($process.ProcessName) (PID: $pid)" -ForegroundColor Yellow
Write-Host ""
Write-Host "Stopping process..." -ForegroundColor Yellow
Stop-Process -Id $pid -Force -ErrorAction SilentlyContinue
Start-Sleep -Seconds 2
Write-Host "✓ Process stopped" -ForegroundColor Green
}
} else {
Write-Host "No process found on port 8000" -ForegroundColor Green
}
Write-Host ""
Write-Host "Setting environment variables..." -ForegroundColor Yellow
$env:QUIZ_SECRET = "EasyQuiz"
$env:OPENAI_API_KEY = "eyJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6IjI0ZjIwMDU3NTNAZHMuc3R1ZHkuaWl0bS5hYy5pbiJ9.eji7L5I62M9YHoeEKE8ao6eTw8dFjgDIMP9C3lOUXc4"
Write-Host "✓ Environment variables set" -ForegroundColor Green
Write-Host ""
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host "Now start the server manually:" -ForegroundColor Yellow
Write-Host " python -m app.main" -ForegroundColor Cyan
Write-Host ""
Write-Host "Keep that terminal open, then test in another terminal!" -ForegroundColor Yellow