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>
88 lines
3.2 KiB
Python
88 lines
3.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Diagnose time-slot relay not pushing."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
SCRIPT = r"""
|
|
from datetime import datetime, timezone, timedelta
|
|
import subprocess
|
|
from app import db, yt_assign_db, youtube_neko, youtube_relay_db
|
|
from app.youtube_relay_pipeline import (
|
|
youtube_relay_pipeline as pipe,
|
|
pick_source_for_group,
|
|
_group_in_active_slot,
|
|
_live_room_ids,
|
|
)
|
|
|
|
db.init_db()
|
|
cfg = db.get_settings_map()
|
|
BJ = timezone(timedelta(hours=8))
|
|
now = datetime.now(BJ)
|
|
print('beijing', now.strftime('%Y-%m-%d %H:%M:%S'))
|
|
print('time_slot', cfg.get('youtube_relay_time_slot_mode'))
|
|
print('auto_push', cfg.get('youtube_relay_enabled'))
|
|
print('exclusive', cfg.get('youtube_relay_exclusive_live'))
|
|
st0 = pipe.status()
|
|
print('status_enabled', st0.get('enabled'), 'running', st0.get('running'))
|
|
print('last_error', (st0.get('last_error') or getattr(pipe, 'last_error', '') or '')[:240])
|
|
print('exclusive_winner', getattr(pipe, '_exclusive_winner', None))
|
|
|
|
groups = yt_assign_db.list_groups(include_urls=True, include_secret=True)
|
|
sched = yt_assign_db.build_rotation_schedule(include_urls=False, groups=groups, keyed_only=True)
|
|
print('schedule', 'N', sched.get('channel_count'), 'slot_h', sched.get('slot_hours'))
|
|
for ch in sched.get('channels') or []:
|
|
mark = 'ACTIVE' if ch.get('active') else ''
|
|
print('SLOT', ch.get('name'), ch.get('start'), '-', ch.get('end'), mark, 'gid', ch.get('group_id'))
|
|
|
|
live = _live_room_ids()
|
|
print('live_rooms', len(live), list(live)[:10])
|
|
|
|
for g in groups:
|
|
keyed = bool(str(g.get('stream_key') or '').strip() or g.get('has_stream_key'))
|
|
if not keyed:
|
|
continue
|
|
gid = g.get('id')
|
|
in_slot = _group_in_active_slot(g, keyed_only=True)
|
|
src = pick_source_for_group(g, respect_schedule=True, time_slot_mode=True)
|
|
st = youtube_relay_db.get_relay_state(gid) or {}
|
|
neko_id = int(g.get('neko_instance_id') or 0)
|
|
print('---')
|
|
print('G', g.get('name'), 'enabled', g.get('enabled'), 'keyed', keyed, 'neko', neko_id, 'neko_en', g.get('neko_enabled'))
|
|
print(' in_slot', in_slot, 'src', (src or {}).get('room_id'), (src or {}).get('anchor_name'))
|
|
print(' relay', st.get('status'), 'err', str(st.get('error') or '')[:200])
|
|
logs = st.get('recent_log') or []
|
|
for line in logs[-5:]:
|
|
print(' LOG', line)
|
|
|
|
try:
|
|
print('neko', youtube_neko.status_summary())
|
|
except Exception as exc:
|
|
print('neko_err', exc)
|
|
|
|
r = subprocess.run(['bash','-lc',"ps aux | grep '[f]fmpeg' | head -15"], capture_output=True, text=True)
|
|
print('ffmpeg_lines', len([x for x in r.stdout.splitlines() if x.strip()]))
|
|
print(r.stdout[:1500] or '(no ffmpeg)')
|
|
"""
|
|
|
|
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()
|
|
with sftp.file("/tmp/_diag_slot_now.py", "w") as f:
|
|
f.write(SCRIPT)
|
|
sftp.close()
|
|
_, o, e = c.exec_command(
|
|
"cd /opt/douyinWEB/backend && PYTHONPATH=. .venv/bin/python /tmp/_diag_slot_now.py 2>&1",
|
|
timeout=120,
|
|
)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
err = e.read().decode("utf-8", "replace")
|
|
if err.strip():
|
|
print(err[-800:])
|
|
c.close()
|