# -*- coding: utf-8 -*- """Deploy fixed confirm + retest graceful End on neko-7.""" from __future__ import annotations import sys from pathlib import Path import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") ROOT = Path(__file__).resolve().parents[1] 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) sftp = c.open_sftp() sftp.put(str(ROOT / "backend/neko/cdp_end_stream.py"), "/tmp/cdp_end_stream.py") runner = r'''#!/bin/bash set -euo pipefail install -m 0644 /tmp/cdp_end_stream.py /opt/douyinWEB/backend/neko/cdp_end_stream.py NAME=douyinweb-neko-7 NEKO_ID=7 CHANNEL_PK=82102486-f5d7-434c-b508-4c6a10c5f325 cd /opt/douyinWEB/backend # Pause auto-relay so ffmpeg does not respawn mid-test ./.venv/bin/python - <<'PY' from app import db cfg=db.get_settings_map() open("/tmp/relay_prev.json","w").write(repr({ "youtube_relay_enabled": bool(cfg.get("youtube_relay_enabled")), "youtube_relay_timeslot_test": bool(cfg.get("youtube_relay_timeslot_test")), })) db.update_settings_map({"youtube_relay_enabled": False}) print("relay_paused") PY echo '=== BEFORE ===' 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 ("live_status","on_air","health")})' echo '=== kill ffmpeg PIDs ===' python3 - <<'PY' import os, signal, subprocess, time for _ in range(3): out=subprocess.check_output(["ps","-eo","pid,args"], text=True, errors="replace") n=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) try: os.kill(pid, signal.SIGTERM); n+=1 except ProcessLookupError: pass print("killed_batch", n) time.sleep(1) PY sleep 10 echo '=== MID ===' 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 ("live_status","on_air","health")})' echo '=== end_live_session ===' ./.venv/bin/python - < 22000 else out, flush=True) c.close() raise SystemExit(code)