#!/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())