forked from mtusi2026/mtusi2026lab3
Лабораторная 3: реализован стенд с балансировщиком и идемпотентностью
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Stop exactly ONE API replica selected by TARGET_INSTANCE_ID — called by resilience.py failover test."""
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
|
||||
def main():
|
||||
target = os.environ.get("TARGET_INSTANCE_ID")
|
||||
if not target:
|
||||
print("TARGET_INSTANCE_ID not set", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
# Change to repo root
|
||||
repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
os.chdir(repo_root)
|
||||
|
||||
# Stop the specific API service by its compose service name
|
||||
result = subprocess.run(["docker", "compose", "stop", "--timeout", "5", target], capture_output=True)
|
||||
if result.returncode != 0:
|
||||
print(f"docker compose stop {target} failed: {result.stderr.decode()}", file=sys.stderr)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user