# -*- coding: utf-8 -*- """Diagnose why only one Neko posts Studio telemetry.""" import json import subprocess import urllib.request def run(cmd, timeout=20): p = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout) return p.returncode, (p.stdout or "") + (p.stderr or "") def main(): # From each neko: try POST ingest like the extension body = json.dumps( { "source": "diag", "url": "https://studio.youtube.com/video/diagTEST/livestreaming", "live_status": "live", "neko_instance_id": 0, "received_at": __import__("time").time(), "text": "diag you're live concurrent viewers", } ).encode() for base in ( "http://host.docker.internal:8014", "http://172.17.0.1:8014", "http://127.0.0.1:8014", ): code, out = run( [ "docker", "exec", "douyinweb-neko-1", "python3", "-c", f"import urllib.request; r=urllib.request.urlopen(urllib.request.Request({base!r}+'/hub/youtube/live/ingest', data={body!r}, headers={{'Content-Type':'application/json'}}, method='POST'), timeout=8); print(r.status, r.read()[:120])", ], timeout=30, ) print("from_neko1", base, "code", code, out.strip()[:200]) # List live tabs + try stdin scrape on neko 1 and 5 scrape = open("/opt/douyinWEB/backend/neko/cdp_studio_scrape.py", encoding="utf-8").read() for idx in (1, 5, 6): name = f"douyinweb-neko-{idx}" code, out = run( ["docker", "exec", "-i", name, "python3", "-"], timeout=30, ) if False else (0, "") p = subprocess.run( ["docker", "exec", "-i", name, "python3", "-"], input=scrape, capture_output=True, text=True, timeout=30, ) print("scrape", name, "rc", p.returncode, (p.stdout or p.stderr or "")[-300:]) if __name__ == "__main__": main()