douyinWEB/scripts/_check_key_status.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

41 lines
1.8 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"""
# Check API process env + status via same env as systemd
pid=$(systemctl show -p MainPID --value douyinweb-api)
tr '\0' '\n' < /proc/$pid/environ | grep -E 'DY_PUBLIC|DY_NEKO' || true
# Run status as the service user with EnvironmentFile
set -a
source /etc/douyinweb.env 2>/dev/null || true
# also pull from unit
eval $(systemctl show douyinweb-api -p Environment --value | tr ' ' '\n' | sed 's/^/export /')
set +a
cd /opt/douyinWEB/backend
.venv/bin/python - <<'PY'
from app import yt_assign_db
from app.youtube_relay_pipeline import youtube_relay_pipeline
from app.config import settings
print("public", settings.public_base_url)
for g in yt_assign_db.list_groups(include_urls=False, include_secret=False):
print("list", g.get("name"), "has", g.get("has_stream_key"), "masked", g.get("stream_key_masked"), "sk_in", "stream_key" in g)
for g in yt_assign_db.list_groups(include_urls=True, include_secret=True):
sk = str(g.get("stream_key") or "")
print("full", g.get("name"), "len", len(sk), "has", g.get("has_stream_key"))
st = youtube_relay_pipeline.status()
for row in st.get("groups") or []:
print("row", row.get("name"), "has_key", row.get("has_stream_key"), "biz", row.get("business_status"), "neko_url", (row.get("neko") or {}).get("studio_url"))
PY
"""
stdin, stdout, stderr = c.exec_command(cmd, timeout=60)
print(stdout.read().decode("utf-8", "replace"))
err = stderr.read().decode("utf-8", "replace")
if err.strip():
print("ERR", err[:1000])
c.close()