Remove skip-neko-wait on stale telemetry; require new livestreaming heartbeats for 25s after slot switch. Add youtube_live_confirmed to relay status and unit tests. Co-authored-by: Cursor <cursoragent@cursor.com>
79 lines
2.2 KiB
Python
79 lines
2.2 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
|
|
curl -sS http://127.0.0.1:8014/api/youtube/relay/status | python3 -c "
|
|
import sys,json
|
|
d=json.load(sys.stdin)
|
|
print('slot', d.get('settings',{}).get('youtube_relay_time_slot_mode'))
|
|
print('studio_live', d.get('studio_live'))
|
|
for g in d.get('groups',[]):
|
|
if g.get('is_pushing') or 'Evan' in str(g.get('name','')):
|
|
print('---', g.get('name'), g.get('business_status'), g.get('status'))
|
|
rl=g.get('recent_log')
|
|
if isinstance(rl,list):
|
|
for line in rl[-5:]:
|
|
print(' ', line[:180])
|
|
"
|
|
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()
|