# -*- coding: utf-8 -*- import paramiko c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False) _, o, _ = c.exec_command(""" set +e systemctl reset-failed douyinweb-web systemctl restart douyinweb-api systemctl restart douyinweb-web sleep 8 systemctl --no-pager -l status douyinweb-web | head -35 ss -lntp | grep -E '4014|8014|8333' journalctl -u douyinweb-web -n 40 --no-pager curl -s -o /dev/null -w 'web:%{http_code}\n' --max-time 20 http://127.0.0.1:4014/ curl -s -o /dev/null -w 'api:%{http_code}\n' --max-time 10 http://127.0.0.1:8014/api/health python3 - <<'PY' import json,urllib.request d=json.load(urllib.request.urlopen('http://127.0.0.1:8014/api/sessions/active', timeout=15)) print('active', d.get('total')) for s in (d.get('sessions') or [])[:3]: print(s.get('anchor_name'), s.get('cover_url'), s.get('cover_path','')[:70]) sid=s.get('id') if sid: try: r=urllib.request.urlopen(f'http://127.0.0.1:8014/api/sessions/{sid}/cover', timeout=20) print(' cover_http', r.status, r.headers.get('content-type'), 'len', r.headers.get('content-length')) except Exception as e: print(' cover_err', e) PY """, timeout=120, get_pty=True) print(o.read().decode("utf-8", errors="replace")[-7000:]) c.close()