# -*- coding: utf-8 -*- """Full graceful-end selftest on dylive neko-7 (avoid pkill matching this script).""" from __future__ import annotations import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect( "107.173.30.245", 22, "root", "Xiao4669805", timeout=45, allow_agent=False, look_for_keys=False, banner_timeout=120, ) # Upload runner script to avoid pkill -f matching inline heredoc with rtmps URL runner = r'''#!/bin/bash set -euo pipefail NAME=douyinweb-neko-7 NEKO_ID=7 CHANNEL_PK=82102486-f5d7-434c-b508-4c6a10c5f325 echo '=== 1 BEFORE scrape ===' docker exec -i "$NAME" python3 - < /opt/douyinWEB/backend/neko/cdp_studio_scrape.py | tee /tmp/before.json | python3 -c 'import sys,json;d=json.load(sys.stdin);print({k:d.get(k) for k in ("ok","live_status","on_air","health","url")})' echo '=== 2 stop ffmpeg by PID ===' python3 - <<'PY' import os, signal, subprocess out=subprocess.check_output(["ps","-eo","pid,args"], text=True, errors="replace") killed=0 for line in out.splitlines(): if "ffmpeg" in line and "youtube" in line.lower() and "python" not in line: pid=int(line.split(None,1)[0]) print("kill", pid, line[:120]) try: os.kill(pid, signal.SIGTERM) killed+=1 except ProcessLookupError: pass print("killed", killed) PY sleep 2 pgrep -af '[f]fmpeg' | head -3 || echo 'ffmpeg_gone' echo '=== 3 wait encoder lost ===' sleep 8 docker exec -i "$NAME" python3 - < /opt/douyinWEB/backend/neko/cdp_studio_scrape.py | tee /tmp/mid.json | python3 -c 'import sys,json;d=json.load(sys.stdin);print({k:d.get(k) for k in ("ok","live_status","on_air","health")})' echo '=== 4 end_live_session ===' cd /opt/douyinWEB/backend ./.venv/bin/python - < 20000 else out, flush=True) c.close() raise SystemExit(code)