forked from mtusi2026/mtusi2026lab3
lab3: Compose+Nginx, две API-реплики и идемпотентность
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env python3
|
||||
from messenger.db import apply_migrations, close_engine, init_engine
|
||||
|
||||
|
||||
def main() -> None:
|
||||
init_engine()
|
||||
try:
|
||||
apply_migrations()
|
||||
print("migrations applied")
|
||||
finally:
|
||||
close_engine()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,4 @@
|
||||
@echo off
|
||||
cd /d "%~dp0\.."
|
||||
docker compose --env-file .env restart postgres api1 api2 lb
|
||||
exit /b %ERRORLEVEL%
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
docker compose --env-file .env restart postgres api1 api2 lb
|
||||
@@ -0,0 +1,12 @@
|
||||
@echo off
|
||||
cd /d "%~dp0\.."
|
||||
if "%TARGET_INSTANCE_ID%"=="" (
|
||||
echo TARGET_INSTANCE_ID is required >&2
|
||||
exit /b 1
|
||||
)
|
||||
if /I not "%TARGET_INSTANCE_ID%"=="api1" if /I not "%TARGET_INSTANCE_ID%"=="api2" (
|
||||
echo unknown TARGET_INSTANCE_ID: %TARGET_INSTANCE_ID% >&2
|
||||
exit /b 1
|
||||
)
|
||||
docker compose --env-file .env stop %TARGET_INSTANCE_ID%
|
||||
exit /b %ERRORLEVEL%
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
: "${TARGET_INSTANCE_ID:?test provides target API instance alias}"
|
||||
|
||||
case "$TARGET_INSTANCE_ID" in
|
||||
api1|api2)
|
||||
docker compose --env-file .env stop "$TARGET_INSTANCE_ID"
|
||||
;;
|
||||
*)
|
||||
printf '%s\n' "unknown TARGET_INSTANCE_ID: $TARGET_INSTANCE_ID" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user