Выполнение 3 лабораторной на оценку 3
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user