Files
mtusi2026lab7/scripts/restart.py
T
Wladislava1 54dcf70ea6
Skeleton contracts / contracts (pull_request) Canceled after 0s
Lab7: HTTPS, mTLS, OpenBao, трек 2 PKI на оценку 5
2026-11-17 00:25:48 +03:00

27 lines
1.0 KiB
Python

#!/usr/bin/env python3
"""Windows-friendly persistence hook: restart stateful services, keep volumes."""
from __future__ import annotations
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def run(args: list[str]) -> None:
subprocess.check_call(args, cwd=ROOT)
def main() -> int:
run(["docker", "compose", "--env-file", ".env", "restart", "postgres", "redis", "minio", "rabbitmq", "prometheus", "loki", "tempo", "openbao"])
run(["docker", "compose", "--env-file", ".env", "up", "-d", "--wait", "--no-deps", "postgres", "redis", "minio", "rabbitmq", "prometheus", "loki", "tempo", "openbao"])
# OpenBao may be sealed after restart; operator unseal without printing keys.
subprocess.call([sys.executable, "-X", "utf8", str(ROOT / "scripts" / "openbao_bootstrap.py")], cwd=ROOT, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
run(["docker", "compose", "--env-file", ".env", "restart", "api", "worker"])
return 0
if __name__ == "__main__":
raise SystemExit(main())