21 lines
749 B
PowerShell
21 lines
749 B
PowerShell
. "$PSScriptRoot\env.ps1"
|
|
|
|
$PidFile = Join-Path $PidDir "frontend.pid"
|
|
if (-not (Test-Path -LiteralPath $PidFile)) {
|
|
Write-Host "Frontend is not running (no pid file)."
|
|
exit 0
|
|
}
|
|
|
|
$rawPid = Get-Content -LiteralPath $PidFile | Select-Object -First 1
|
|
$processId = 0
|
|
if (-not [int]::TryParse([string]$rawPid, [ref]$processId) -or -not (Get-Process -Id $processId -ErrorAction SilentlyContinue)) {
|
|
Remove-Item -LiteralPath $PidFile -Force -ErrorAction SilentlyContinue
|
|
Write-Host "Frontend is not running (stale pid file removed)."
|
|
exit 0
|
|
}
|
|
|
|
Write-Host "Stopping frontend (pid $processId)..."
|
|
Stop-ProcessTree -ProcessId $processId
|
|
Remove-Item -LiteralPath $PidFile -Force -ErrorAction SilentlyContinue
|
|
Write-Host "Frontend stopped."
|