forked from mtusi2026/mtusi2026lab5
ЛР 5 — БПИ2302 — Щербацевич — на 4
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
$target = $env:TARGET_INSTANCE_ID
|
||||
if (-not $target) {
|
||||
Write-Error "TARGET_INSTANCE_ID is required"
|
||||
exit 1
|
||||
}
|
||||
$ids = docker ps -q --filter label=com.docker.compose.service=api --filter label=com.docker.compose.project=mtusi-lab5
|
||||
$found = ""
|
||||
foreach ($id in $ids) {
|
||||
if (-not $id) { continue }
|
||||
$hostName = docker inspect -f "{{.Config.Hostname}}" $id
|
||||
$short = $id.Substring(0, [Math]::Min(12, $id.Length))
|
||||
if ($hostName -eq $target -or $short -eq $target -or $id -eq $target) {
|
||||
$found = $id
|
||||
break
|
||||
}
|
||||
}
|
||||
if (-not $found) {
|
||||
Write-Error "api replica not found"
|
||||
exit 1
|
||||
}
|
||||
docker stop -t 5 $found | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
Reference in New Issue
Block a user