181 lines
5.6 KiB
PowerShell
181 lines
5.6 KiB
PowerShell
# EVE Application Kill Script for Windows
|
|
# Stops all running EVE development processes
|
|
|
|
# Function to print colored output
|
|
function Write-ColorOutput($ForegroundColor) {
|
|
$fc = $host.UI.RawUI.ForegroundColor
|
|
$host.UI.RawUI.ForegroundColor = $ForegroundColor
|
|
if ($args) {
|
|
Write-Output $args
|
|
}
|
|
$host.UI.RawUI.ForegroundColor = $fc
|
|
}
|
|
|
|
function Log-Info($message) {
|
|
Write-ColorOutput Cyan "[INFO] $message"
|
|
}
|
|
|
|
function Log-Success($message) {
|
|
Write-ColorOutput Green "[SUCCESS] $message"
|
|
}
|
|
|
|
function Log-Warning($message) {
|
|
Write-ColorOutput Yellow "[WARNING] $message"
|
|
}
|
|
|
|
function Log-Found($message) {
|
|
Write-ColorOutput Yellow "[FOUND] $message"
|
|
}
|
|
|
|
function Log-Killing($message) {
|
|
Write-ColorOutput Blue "[KILLING] $message"
|
|
}
|
|
|
|
# Print header
|
|
Write-Host ""
|
|
Write-Host "╔════════════════════════════════════════════════════════╗" -ForegroundColor Red
|
|
Write-Host "║ Stopping EVE Development Server ║" -ForegroundColor Red
|
|
Write-Host "╚════════════════════════════════════════════════════════╝" -ForegroundColor Red
|
|
Write-Host ""
|
|
|
|
$killedAny = $false
|
|
|
|
# Function to kill process and its children
|
|
function Stop-ProcessTree {
|
|
param(
|
|
[Parameter(Mandatory=$true)]
|
|
[int]$ProcessId
|
|
)
|
|
|
|
try {
|
|
$process = Get-Process -Id $ProcessId -ErrorAction SilentlyContinue
|
|
if ($process) {
|
|
# Get child processes
|
|
$children = Get-CimInstance Win32_Process | Where-Object { $_.ParentProcessId -eq $ProcessId }
|
|
|
|
# Kill children first
|
|
foreach ($child in $children) {
|
|
Stop-ProcessTree -ProcessId $child.ProcessId
|
|
}
|
|
|
|
# Kill the process
|
|
Log-Killing "Process $ProcessId ($($process.Name))"
|
|
Stop-Process -Id $ProcessId -Force -ErrorAction SilentlyContinue
|
|
$script:killedAny = $true
|
|
}
|
|
} catch {
|
|
# Silently continue if process doesn't exist
|
|
}
|
|
}
|
|
|
|
Log-Info "Searching for EVE processes..."
|
|
|
|
# Kill Node.js processes running Vite or Tauri
|
|
$nodeProcesses = Get-Process -Name "node" -ErrorAction SilentlyContinue
|
|
foreach ($proc in $nodeProcesses) {
|
|
try {
|
|
$cmdLine = (Get-CimInstance Win32_Process -Filter "ProcessId = $($proc.Id)").CommandLine
|
|
if ($cmdLine -match "vite|tauri") {
|
|
Log-Found "Node process: $($proc.Id)"
|
|
Stop-ProcessTree -ProcessId $proc.Id
|
|
}
|
|
} catch {
|
|
# Continue if we can't get command line
|
|
}
|
|
}
|
|
|
|
# Kill Cargo processes
|
|
$cargoProcesses = Get-Process -Name "cargo" -ErrorAction SilentlyContinue
|
|
foreach ($proc in $cargoProcesses) {
|
|
try {
|
|
$cmdLine = (Get-CimInstance Win32_Process -Filter "ProcessId = $($proc.Id)").CommandLine
|
|
if ($cmdLine -match "eve") {
|
|
Log-Found "Cargo process: $($proc.Id)"
|
|
Stop-ProcessTree -ProcessId $proc.Id
|
|
}
|
|
} catch {
|
|
# Continue
|
|
}
|
|
}
|
|
|
|
# Kill eve-assistant processes
|
|
$eveProcesses = Get-Process -Name "eve-assistant" -ErrorAction SilentlyContinue
|
|
if ($eveProcesses) {
|
|
Log-Found "EVE application processes"
|
|
foreach ($proc in $eveProcesses) {
|
|
Stop-ProcessTree -ProcessId $proc.Id
|
|
}
|
|
}
|
|
|
|
# Kill rustc processes related to eve
|
|
$rustcProcesses = Get-Process -Name "rustc" -ErrorAction SilentlyContinue
|
|
foreach ($proc in $rustcProcesses) {
|
|
try {
|
|
$cmdLine = (Get-CimInstance Win32_Process -Filter "ProcessId = $($proc.Id)").CommandLine
|
|
if ($cmdLine -match "eve") {
|
|
Log-Found "Rust compiler process: $($proc.Id)"
|
|
Stop-ProcessTree -ProcessId $proc.Id
|
|
}
|
|
} catch {
|
|
# Continue
|
|
}
|
|
}
|
|
|
|
# Kill by PID file if exists
|
|
if (Test-Path ".dev\run.pid") {
|
|
$pid = Get-Content ".dev\run.pid" -ErrorAction SilentlyContinue
|
|
if ($pid) {
|
|
$proc = Get-Process -Id $pid -ErrorAction SilentlyContinue
|
|
if ($proc) {
|
|
Log-Found "Run script process (PID: $pid)"
|
|
Stop-ProcessTree -ProcessId $pid
|
|
}
|
|
}
|
|
Remove-Item ".dev\run.pid" -Force -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
Write-Host ""
|
|
Log-Info "Checking for processes on default ports..."
|
|
|
|
# Function to kill process using a port
|
|
function Stop-ProcessOnPort {
|
|
param([int]$Port)
|
|
|
|
try {
|
|
$connections = Get-NetTCPConnection -LocalPort $Port -ErrorAction SilentlyContinue
|
|
foreach ($conn in $connections) {
|
|
$proc = Get-Process -Id $conn.OwningProcess -ErrorAction SilentlyContinue
|
|
if ($proc) {
|
|
# Check if it's related to our project
|
|
$cmdLine = (Get-CimInstance Win32_Process -Filter "ProcessId = $($proc.Id)").CommandLine
|
|
if ($cmdLine -match "eve|tauri|vite") {
|
|
Log-Found "Process on port $Port ($($proc.Name))"
|
|
Stop-ProcessTree -ProcessId $proc.Id
|
|
}
|
|
}
|
|
}
|
|
} catch {
|
|
# Port not in use or no permission
|
|
}
|
|
}
|
|
|
|
# Check common ports
|
|
Stop-ProcessOnPort -Port 5173 # Vite
|
|
Stop-ProcessOnPort -Port 1420 # Tauri
|
|
Stop-ProcessOnPort -Port 3000 # Alternative dev server
|
|
Stop-ProcessOnPort -Port 8080 # Alternative dev server
|
|
|
|
# Clean up lock files
|
|
if (Test-Path "src-tauri\target\.rustc_info.json.lock") {
|
|
Remove-Item "src-tauri\target\.rustc_info.json.lock" -Force -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
Write-Host ""
|
|
if ($killedAny) {
|
|
Log-Success "All EVE processes stopped ✓"
|
|
} else {
|
|
Log-Info "No EVE processes were running"
|
|
}
|
|
|
|
Write-Host ""
|