Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP. Co-authored-by: Cursor <cursoragent@cursor.com>
36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
import paramiko
|
|
|
|
if hasattr(sys.stdout, "reconfigure"):
|
|
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("108.174.50.68", 22, "root", "Xiao4669805", timeout=45, allow_agent=False, look_for_keys=False)
|
|
sftp = c.open_sftp()
|
|
sftp.put(str(ROOT / "backend/app/youtube_relay_pipeline.py"), "/opt/douyinWEB/backend/app/youtube_relay_pipeline.py")
|
|
sftp.close()
|
|
|
|
# clear zombie relay state + kill defunct awareness via api restart
|
|
script = r"""
|
|
cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'
|
|
from app import youtube_relay_db
|
|
for st in youtube_relay_db.list_relay_states():
|
|
gid = st.get('group_id')
|
|
print('clear', gid, st.get('status'), st.get('ffmpeg_pid'))
|
|
youtube_relay_db.clear_relay_state(gid, status='idle', error='主播已下播或 CDN 断流;开播后请点「开始」或开启自动推流')
|
|
print('done')
|
|
PY
|
|
pkill -9 -f 'ffmpeg.*rtmps' 2>/dev/null || true
|
|
systemctl restart douyinweb-api
|
|
"""
|
|
c.exec_command(script, timeout=5)
|
|
time.sleep(8)
|
|
_, o, _ = c.exec_command("systemctl is-active douyinweb-api; pgrep -a ffmpeg | head -2 || echo no_ffmpeg", timeout=20)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
c.close()
|