Добавить варианты изображений, очистку staging, replay и сценарии отказа
This commit is contained in:
@@ -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()
|
||||
@@ -0,0 +1,2 @@
|
||||
@echo off
|
||||
python "%~dp0actions.py" restart
|
||||
Executable
+5
@@ -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
|
||||
@@ -0,0 +1,2 @@
|
||||
@echo off
|
||||
python "%~dp0actions.py" stop-one
|
||||
Executable
+16
@@ -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
|
||||
Reference in New Issue
Block a user