Files
mtusi2026lab2/scripts/restart.ps1
T
SashaKirupina 0c179a44a3
Skeleton contracts / contracts (pull_request) Canceled after 0s
ЛР 2 — БПИ2304 — Кирюпина — на 3
2026-11-05 13:46:46 +03:00

21 lines
991 B
PowerShell

$ErrorActionPreference = 'Stop'
Push-Location (Split-Path $PSScriptRoot -Parent)
try {
function Snapshot {
foreach ($service in @('api', 'db')) {
$containerId = docker compose ps -q $service
if ($LASTEXITCODE -ne 0 -or -not $containerId) { throw 'Container not found' }
docker inspect --format '{{.Name}} started={{.State.StartedAt}} status={{.State.Status}} volumes={{range .Mounts}}{{.Name}} {{end}}' $containerId
if ($LASTEXITCODE -ne 0) { throw 'Inspect failed' }
}
}
Snapshot | Set-Content evidence/restart-scope.txt
docker compose stop api db
if ($LASTEXITCODE -ne 0) { throw 'Stop failed' }
docker compose up -d --wait --wait-timeout 30 db
if ($LASTEXITCODE -ne 0) { throw 'Database start failed' }
docker compose up -d --wait --wait-timeout 30 api
if ($LASTEXITCODE -ne 0) { throw 'API start failed' }
Snapshot | Add-Content evidence/restart-scope.txt
} finally { Pop-Location }