$port = 3000
$conn = Get-NetTCPConnection -LocalPort $port -ErrorAction SilentlyContinue
if ($conn) {
    Write-Host "Killing PID $($conn.OwningProcess)..."
    Stop-Process -Id $conn.OwningProcess -Force -ErrorAction SilentlyContinue
    Start-Sleep -Seconds 2
}
Write-Host "Starting server..."
Set-Location C:\Users\caoyg\ai\audio-tts\audio_codebuddy\server
Start-Process -NoNewWindow -FilePath "npx.cmd" -ArgumentList "tsx","src\app.ts"
Write-Host "Server started"
