启动脚本

This commit is contained in:
Yeomai committed 2026-10-18 17:20:09 +08:00
1 parent 202a81d0a9
commit 5e024f77a2
3 files changed
+86

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
$root = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
$listener = Get-NetTCPConnection -LocalPort 3000 -State Listen -ErrorAction SilentlyContinue |
Select-Object -First 1
if (-not $listener) {
Write-Host 'PicHost development server is not running.'
exit 2
}
$process = Get-CimInstance Win32_Process -Filter ('ProcessId=' + $listener.OwningProcess)
if (-not $process -or $process.CommandLine -notlike ('*' + $root + '*')) {
Write-Host 'Port 3000 belongs to another program. Stop cancelled.'
exit 3
}
taskkill /PID $listener.OwningProcess /T /F | Out-Null
if ($LASTEXITCODE -ne 0) {
exit 1
}
Write-Host 'PicHost development server stopped.'
exit 0