Добавить варианты изображений, очистку staging, replay и сценарии отказа

This commit is contained in:
2026-11-20 06:18:12 +03:00
parent a0ec26d96d
commit e376ede0a2
12 changed files with 258 additions and 1 deletions
+31
View File
@@ -0,0 +1,31 @@
"""Windows hooks for the public resilience client."""
import os
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def docker(*args):
return subprocess.check_output(['docker', *args], cwd=ROOT, text=True).strip()
def main():
if sys.argv[1] == 'restart':
docker('compose', 'restart', '-t', '4', 'db', 'redis', 's3', 'broker', 'api',
'dispatcher', 'worker', 'staging-cleaner', 'lb')
return
target = os.environ['TARGET_INSTANCE_ID']
for container in docker('compose', 'ps', '-q', 'api').splitlines():
name = docker('inspect', '--format', '{{.Config.Hostname}}', container)
prefix, _, suffix = target.rpartition('-')
if prefix == name and len(suffix) == 8:
docker('stop', '-t', '2', container)
return
raise SystemExit('API instance not found')
if __name__ == '__main__':
main()
+2
View File
@@ -0,0 +1,2 @@
@echo off
python "%~dp0actions.py" restart
+5
View File
@@ -0,0 +1,5 @@
#!/bin/sh
set -eu
root="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)"
cd "$root"
docker compose restart -t 4 db redis s3 broker api dispatcher worker staging-cleaner lb
+2
View File
@@ -0,0 +1,2 @@
@echo off
python "%~dp0actions.py" stop-one
+16
View File
@@ -0,0 +1,16 @@
#!/bin/sh
set -eu
root="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)"
cd "$root"
: "${TARGET_INSTANCE_ID:?}"
for container in $(docker compose ps -q api); do
hostname="$(docker inspect --format '{{.Config.Hostname}}' "$container")"
case "$TARGET_INSTANCE_ID" in
"$hostname"-????????)
docker compose ps -q api | grep -Fx "$container" >/dev/null
docker stop -t 2 "$container" >/dev/null
exit 0
;;
esac
done
exit 1