45 lines
1.7 KiB
PowerShell
45 lines
1.7 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Vignette 로컬 개발 스택(게이트웨이 9099 + API 8000 + 웹 5173)을 정리한다.
|
|
.DESCRIPTION
|
|
커맨드라인 기준으로 정확히 종료한다(고아 워커/리로더 포함). scripts/dev-up.ps1 의 짝.
|
|
기본은 Postgres 컨테이너를 보존한다. 함께 멈추려면 -Db를 명시한다.
|
|
.EXAMPLE
|
|
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\dev-down.ps1
|
|
#>
|
|
param(
|
|
[int]$ApiPort = 8000,
|
|
[switch]$Db
|
|
)
|
|
$ErrorActionPreference = 'SilentlyContinue'
|
|
|
|
function Stop-Stale([string]$pattern, [string]$label) {
|
|
Get-CimInstance Win32_Process |
|
|
Where-Object { ($_.Name -eq 'python.exe' -or $_.Name -eq 'node.exe') -and $_.CommandLine -and $_.CommandLine -match $pattern } |
|
|
ForEach-Object {
|
|
Write-Host (" stop {0,-8} PID {1}" -f $label, $_.ProcessId)
|
|
Stop-Process -Id $_.ProcessId -Force
|
|
}
|
|
}
|
|
|
|
Write-Host "로컬 dev 스택 종료..."
|
|
Stop-Stale 'engine_gateway\.gateway' 'gateway'
|
|
Stop-Stale 'app\.main:app' 'api'
|
|
Stop-Stale 'vite' 'web'
|
|
Get-NetTCPConnection -LocalPort $ApiPort -State Listen -ErrorAction SilentlyContinue |
|
|
Select-Object -ExpandProperty OwningProcess -Unique |
|
|
Where-Object { $_ -and $_ -ne 0 } |
|
|
ForEach-Object { Stop-Process -Id $_ -Force }
|
|
if ($Db) {
|
|
if (Get-Command docker -ErrorAction SilentlyContinue) {
|
|
$running = docker ps --filter name=vignette-dev-db --format '{{.Names}}' 2>$null
|
|
if ($running -match 'vignette-dev-db') {
|
|
Write-Host ' stop db vignette-dev-db'
|
|
docker stop vignette-dev-db 1>$null
|
|
}
|
|
}
|
|
} else {
|
|
Write-Host ' keep db vignette-dev-db (필요하면 -Db로 중지)'
|
|
}
|
|
Start-Sleep -Seconds 1
|
|
Write-Host "완료."
|