Complete lab2 grade 4 implementation and report
This commit is contained in:
+5
-5
@@ -3,7 +3,7 @@ Set-Location (Split-Path -Parent $PSScriptRoot)
|
||||
|
||||
function Read-Containers {
|
||||
$result = @()
|
||||
foreach ($service in @('api', 'postgres')) {
|
||||
foreach ($service in @('api', 'postgres', 'redis')) {
|
||||
$containerID = docker compose ps -q $service
|
||||
if ($LASTEXITCODE -ne 0 -or -not $containerID) { throw "Cannot find $service container" }
|
||||
$json = docker inspect --format '{{json .}}' $containerID
|
||||
@@ -22,9 +22,9 @@ function Read-Containers {
|
||||
}
|
||||
|
||||
$before = @(Read-Containers)
|
||||
docker compose stop api postgres
|
||||
docker compose stop api postgres redis
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Stop failed' }
|
||||
docker compose up -d --wait postgres
|
||||
docker compose up -d --wait postgres redis
|
||||
if ($LASTEXITCODE -ne 0) { throw 'PostgreSQL restart failed' }
|
||||
docker compose up -d --wait api
|
||||
if ($LASTEXITCODE -ne 0) { throw 'API restart failed' }
|
||||
@@ -39,6 +39,6 @@ foreach ($old in $before) {
|
||||
}
|
||||
}
|
||||
$evidence = [ordered]@{ before = $before; after = $after; volumes_preserved = $true }
|
||||
$path = Join-Path $PWD 'evidence/restart-containers.json'
|
||||
$path = Join-Path $PWD 'evidence/restart-all-containers.json'
|
||||
[System.IO.File]::WriteAllText($path, ($evidence | ConvertTo-Json -Depth 5), [System.Text.UTF8Encoding]::new($false))
|
||||
Write-Output 'PASS: API and PostgreSQL restarted; named volumes preserved.'
|
||||
Write-Output 'PASS: API, PostgreSQL and Redis restarted; named volumes preserved.'
|
||||
|
||||
Reference in New Issue
Block a user