Files
mtusi2026lab7/scripts/restart.py
T
Angelika ee9d70af85
Skeleton contracts / contracts (pull_request) Blocked by required conditions
Lab7 solution / integration (pull_request) Blocked by required conditions
ЛР 7 — БВТ2303 — Брезгунова — на 5
2026-12-04 17:07:57 +03:00

19 lines
1008 B
Python

"""Persistence hook: restart all actual services and explicit operator unseal."""
from pathlib import Path
import subprocess
import time
ROOT=Path(__file__).resolve().parents[1]
DC=['docker','compose','--env-file','.env']
def call(*args):subprocess.run(DC+list(args),cwd=ROOT,check=True,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
sidecars=['api1-tls','api2-tls','broker-tls','otel-collector-tls','prometheus-tls','loki-tls','tempo-tls','grafana-tls']
# Stop shared-network sidecars before replacing the parent's namespace.
call('stop',*sidecars)
call('restart','postgres','s3','broker','openbao','otel-collector','prometheus','loki','tempo','grafana','api1','api2','publisher','worker','janitor','lb')
for _ in range(20):
try:
call('run','--rm','--no-deps','operator','python','scripts/bootstrap.py','unseal')
break
except subprocess.CalledProcessError:time.sleep(1)
else:raise RuntimeError('operator unseal failed')
call('up','-d','--no-deps','--force-recreate',*sidecars)