#!/usr/bin/env python3 """Non-root, readiness, graceful stop, old-session recovery, and log privacy.""" import argparse import json from pathlib import Path import platform import subprocess import sys import time ROOT=Path(__file__).resolve().parents[1] sys.path.insert(0,str(ROOT/'tests')) from client import Client from integration import compose, ready, sql p=argparse.ArgumentParser();p.add_argument('--base-url',default='http://localhost:8082');args=p.parse_args() c=Client(args.base_url);ready(c);a=c.user('lifecycle') chat=c.call('POST','/api/v1/chats',201,actor=a,body={'title':'Lifecycle','member_ids':[a['id']]},schema='Chat')['json'] marker='synthetic-private-body-marker';msg=c.message(a,chat,marker)['json'] container=compose('ps','-q','api') inspect=lambda:json.loads(subprocess.check_output(['docker','inspect',container],text=True))[0] before=inspect() # HTTP readiness can precede Docker's next periodic healthcheck after restart. deadline=time.monotonic()+20 while before['State']['Health']['Status']!='healthy' and time.monotonic()