#!/usr/bin/env python3 """Recover dylive neko-12 chrome after FATAL spawn; dedupe key registry.""" from __future__ import annotations import sys import time import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") def connect(): c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) for i in range(10): try: c.connect( "107.173.30.245", 22, "root", "Xiao4669805", timeout=60, allow_agent=False, look_for_keys=False, banner_timeout=300, ) return c except Exception as e: print("retry", i, e, flush=True) time.sleep(3 + i) raise SystemExit("ssh fail") c = connect() _i, o, e = c.exec_command( r""" set +e echo '=== chrome supervisor ===' docker exec douyinweb-neko-12 supervisorctl status docker exec douyinweb-neko-12 sh -c 'ls -la /var/log/supervisor/ 2>/dev/null; tail -80 /var/log/supervisor/google-chrome*.log 2>/dev/null; tail -80 /var/log/supervisor/chrome*.log 2>/dev/null' docker exec douyinweb-neko-12 cat /etc/neko/supervisord/google-chrome.conf 2>/dev/null | head -40 echo '=== try start ===' # clear profile locks then start docker exec douyinweb-neko-12 sh -c ' rm -f /home/neko/.config/google-chrome/Singleton* /home/neko/.config/chromium/Singleton* 2>/dev/null supervisorctl stop google-chrome sleep 1 supervisorctl start google-chrome sleep 5 supervisorctl status google-chrome ' # if still fatal, check command docker exec douyinweb-neko-12 sh -c ' ps aux | head -5 ps aux | grep -i chrome | grep -v grep | head curl -sS -m 2 http://127.0.0.1:9222/json/version || echo no_devtools ' # dedupe registry by youtube_channel_id keeping newest non-empty key cd /opt/douyinWEB/backend ./.venv/bin/python - <<'PY' import sqlite3, time from app.db import _connect, _lock from app import yt_stream_key_db with _lock: conn = _connect() yt_stream_key_db.ensure_stream_key_tables(conn) rows = conn.execute('SELECT id, youtube_channel_id, stream_key, updated_at, name FROM yt_stream_key_registry').fetchall() by = {} for r in rows: ycid = (r[1] or '').strip() or f'__id__{r[0]}' prev = by.get(ycid) if prev is None: by[ycid] = r continue # prefer non-empty key, then newer updated_at def score(x): return (1 if (x[2] or '').strip() else 0, float(x[3] or 0)) if score(r) >= score(prev): by[ycid] = r keep = {r[0] for r in by.values()} deleted = 0 for r in rows: if r[0] not in keep: conn.execute('DELETE FROM yt_stream_key_registry WHERE id=?', (r[0],)) deleted += 1 conn.commit() total = conn.execute('SELECT COUNT(*) FROM yt_stream_key_registry').fetchone()[0] print('dedupe_deleted', deleted, 'total', total) conn.close() print(yt_stream_key_db.list_entries(include_secret=False)) PY docker ps --filter name=douyinweb-neko-12 --format '{{.Names}} {{.Status}}' """, timeout=120, ) print((o.read() + e.read()).decode("utf-8", "replace")) c.close() print("DONE")