#!/usr/bin/env python3 """Verify/fix dylive after pausing other stacks.""" from __future__ import annotations import sys import time import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") def connect(): for i in range(12): try: c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect( "107.173.30.245", 22, "root", "Xiao4669805", timeout=60, banner_timeout=180, allow_agent=False, look_for_keys=False, ) print("connected", i, flush=True) return c except Exception as ex: print("retry", i, ex, flush=True) time.sleep(5) raise SystemExit("ssh fail") def run(c, cmd, t=90): print(f"\n$ {cmd[:200]}", flush=True) _i, o, e = c.exec_command(cmd, timeout=t) code = o.channel.recv_exit_status() out = (o.read() + e.read()).decode("utf-8", "replace") print(out[-6000:] if len(out) > 6000 else out, flush=True) return code, out c = connect() try: run(c, "systemctl is-active douyinweb-api douyinweb-web douyinweb-yt douyinweb-pb; " "systemctl restart douyinweb-pb douyinweb-api douyinweb-yt douyinweb-web; sleep 4; " "systemctl is-active douyinweb-api douyinweb-web douyinweb-yt douyinweb-pb; " "uptime; free -h | head -2") run(c, "curl -sS -m 20 http://127.0.0.1:8014/api/health | head -c 400; echo; " "curl -sS -m 20 -o /dev/null -w 'dylive=%{http_code}\\n' https://dylive.nomadro.com/api/health; " "timeout 15 docker ps --format '{{.Names}} {{.Status}}' 2>/dev/null | head -20 || echo docker_slow") finally: c.close() print("DONE", flush=True)