forked from mtusi2026/mtusi2026lab2
lab2
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
cd /d "%~dp0\.."
|
||||
|
||||
echo [restart] restarting api, postgres, redis (volumes preserved)...
|
||||
docker compose --env-file .env restart api postgres redis
|
||||
if errorlevel 1 (
|
||||
echo [restart] docker compose restart failed
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [restart] waiting for api to become healthy...
|
||||
setlocal enabledelayedexpansion
|
||||
for /L %%i in (1,1,60) do (
|
||||
for /f "delims=" %%s in ('docker inspect --format="{{.State.Health.Status}}" mtusi2026lab2-api-1 2^>nul') do set STATUS=%%s
|
||||
if "!STATUS!"=="healthy" (
|
||||
echo [restart] api is healthy after %%is
|
||||
exit /b 0
|
||||
)
|
||||
timeout /t 1 /nobreak >nul
|
||||
)
|
||||
echo [restart] api did not become healthy within 60s
|
||||
exit /b 1
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
docker compose --env-file .env restart api postgres redis
|
||||
|
||||
for i in $(seq 1 60); do
|
||||
status=$(docker inspect --format='{{.State.Health.Status}}' mtusi2026lab2-api-1 2>/dev/null || echo "unknown")
|
||||
if [ "$status" = "healthy" ]; then
|
||||
echo "api is healthy after ${i}s"
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "api did not become healthy within 60s" >&2
|
||||
exit 1
|
||||
Reference in New Issue
Block a user