Detect YouTube Live tab via Chrome DevTools inside the container when ingest heartbeats never arrive; nudge tab focus every 10s. Fixes time-slot relay stuck at starting while Neko UI already shows Live page. Co-authored-by: Cursor <cursoragent@cursor.com>
75 lines
1.9 KiB
Python
75 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Deploy Neko Live-page strict wait before FFmpeg."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
HOST = "108.174.50.68"
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
APP = "/opt/douyinWEB"
|
|
|
|
FILES = [
|
|
"backend/app/youtube_neko.py",
|
|
"backend/app/youtube_relay_pipeline.py",
|
|
]
|
|
|
|
REMOTE = """#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
systemctl restart douyinweb-api
|
|
sleep 5
|
|
systemctl is-active douyinweb-api
|
|
python3 <<'PY'
|
|
import sys
|
|
sys.path.insert(0,'/opt/douyinWEB/backend')
|
|
from app import youtube_neko
|
|
urls = youtube_neko._cdp_live_studio_urls(3)
|
|
print('cdp_urls', urls[:1])
|
|
n = youtube_neko._cdp_nudge_live_studio_tab(3)
|
|
print('nudge', n)
|
|
PY
|
|
echo DONE
|
|
"""
|
|
|
|
|
|
def main() -> None:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, 22, "root", "Xiao4669805", timeout=60, allow_agent=False, look_for_keys=False)
|
|
sftp = c.open_sftp()
|
|
for rel in FILES:
|
|
print("upload", rel)
|
|
sftp.put(str(ROOT / rel), f"{APP}/{rel.replace(chr(92), '/')}")
|
|
with sftp.file("/tmp/deploy_neko_wait.sh", "w") as f:
|
|
f.write(REMOTE)
|
|
sftp.chmod("/tmp/deploy_neko_wait.sh", 0o755)
|
|
sftp.close()
|
|
|
|
chan = c.get_transport().open_session()
|
|
chan.settimeout(120)
|
|
chan.exec_command("bash /tmp/deploy_neko_wait.sh")
|
|
out = b""
|
|
deadline = time.time() + 110
|
|
while time.time() < deadline:
|
|
if chan.recv_ready():
|
|
out += chan.recv(8192)
|
|
elif chan.exit_status_ready():
|
|
while chan.recv_ready():
|
|
out += chan.recv(8192)
|
|
break
|
|
else:
|
|
time.sleep(0.5)
|
|
print(out.decode("utf-8", "replace"))
|
|
if chan.exit_status_ready():
|
|
print("exit", chan.recv_exit_status())
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|