param([switch]$Db)

$Root = Split-Path $PSScriptRoot -Parent
Set-Location $Root

Write-Host '================================'
Write-Host ' EENE Dashboard - Stop'
Write-Host '================================'
Write-Host ''

Write-Host '[1/2] Stopping API/WEB ...'
& "$PSScriptRoot\kill-ports.ps1"
Write-Host '        Done.'
Write-Host ''

Write-Host '[2/2] Database ...'
if ($Db) {
  & "$PSScriptRoot\stop-local-db.ps1"
  docker compose down 2>$null
  Write-Host '        DB stopped (data in data\postgres kept)'
} else {
  Write-Host '        DB kept running - full stop: 서버종료.bat db'
}

Write-Host ''
Write-Host ' Done.'
