Выполнение 3 лабораторной на оценку 3

This commit is contained in:
2026-10-27 14:55:48 +03:00
parent 0ab3a341aa
commit 0ae9cecf83
32 changed files with 1247 additions and 34 deletions
+21
View File
@@ -0,0 +1,21 @@
$ErrorActionPreference = 'Stop'
Set-Location (Join-Path $PSScriptRoot '..')
function Get-ContainerState($phase) {
foreach ($service in @('db', 'redis', 'api1', 'api2', 'lb')) {
$containers = docker compose --env-file .env ps -q $service
if ($LASTEXITCODE -ne 0) { throw "Cannot list $service containers" }
foreach ($container in $containers) {
$name = docker inspect --format '{{.Name}}' $container
$started = docker inspect --format '{{.State.StartedAt}}' $container
"$phase service=$service container=$name started_at=$started"
}
}
}
$before = @(Get-ContainerState 'before')
docker compose --env-file .env restart db redis api1 api2 lb | Out-Null
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$after = @(Get-ContainerState 'after')
$stamp = Get-Date -Format 'yyyy-MM-dd HH:mm:ss K'
Add-Content -Path (Join-Path $PSScriptRoot '..\evidence\persistence-actions.txt') -Value "[$stamp]"
Add-Content -Path (Join-Path $PSScriptRoot '..\evidence\persistence-actions.txt') -Value $before
Add-Content -Path (Join-Path $PSScriptRoot '..\evidence\persistence-actions.txt') -Value $after