douyinWEB/scripts/_reconcile_neko_enabled.py
eric d409e416da Ship physical dual-edge stack, Studio CDP live metrics, and ops tooling.
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>
2026-09-04 22:42:40 -05:00

31 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
import sys
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
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)
cmd = r"""
cd /opt/douyinWEB/backend
.venv/bin/python - <<'PY'
from app import yt_assign_db, youtube_neko
for g in yt_assign_db.list_groups(include_urls=False):
print('ASSIGN', g.get('name'), 'neko_id', g.get('neko_instance_id'), 'enabled', g.get('neko_enabled'))
full = yt_assign_db.get_group(g['id']) or {}
print(' full.enabled', full.get('neko_enabled'))
# force reconcile
groups = yt_assign_db.list_groups(include_urls=False)
print('sync', youtube_neko.sync_for_groups(groups))
for i in youtube_neko.list_instances(2):
print('inst', i['id'], 'running', i.get('running'), 'ready', i.get('ready'))
PY
# restart next frontend if systemd unit exists
systemctl restart douyinweb-web 2>/dev/null || systemctl restart douyinweb-frontend 2>/dev/null || true
ls /etc/systemd/system | grep -i douyin | head
"""
_i, o, e = c.exec_command(cmd, timeout=90)
print(o.read().decode("utf-8", "replace"))
print(e.read().decode("utf-8", "replace")[:800])
c.close()