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>
56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Read-only server check — never touches business data."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
HOST = "107.173.30.245"
|
|
REPO = "/opt/douyinWEB"
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False)
|
|
|
|
|
|
def run(cmd: str, timeout: int = 60) -> str:
|
|
_, o, e = c.exec_command(cmd, timeout=timeout)
|
|
return (o.read() + e.read()).decode("utf-8", "replace").strip()
|
|
|
|
|
|
print("=== READ-ONLY CHECK ===")
|
|
print("[git]", run(f"cd {REPO} && git status -sb && git log --oneline -3 && git stash list | head -5"))
|
|
print(
|
|
"[data fingerprint]",
|
|
run(
|
|
f"stat -c '%n size=%s mtime=%Y' {REPO}/backend/data/monitor.db; "
|
|
f"du -sb {REPO}/backend/data/covers {REPO}/backend/data/clips "
|
|
f"{REPO}/backend/data/tiktok_cookies {REPO}/pb_data 2>/dev/null"
|
|
),
|
|
)
|
|
print("[services]", run("systemctl is-active douyinweb-api douyinweb-web douyinweb-pb"))
|
|
print(
|
|
"[caption_pool code?]",
|
|
run(
|
|
f"test -f {REPO}/backend/app/caption_pool.py && echo HAS_FILE || echo NO_FILE; "
|
|
f"cd {REPO} && git log --oneline origin/test1 -3"
|
|
),
|
|
)
|
|
print(
|
|
"[caption_pool table?]",
|
|
run(
|
|
f"sqlite3 {REPO}/backend/data/monitor.db "
|
|
"\"SELECT name FROM sqlite_master WHERE type='table' AND name='caption_pool'; "
|
|
"SELECT platform, COUNT(*) FROM caption_pool GROUP BY platform;\" 2>&1 || true"
|
|
),
|
|
)
|
|
print(
|
|
"[dirty files only code?]",
|
|
run(f"cd {REPO} && git diff --name-only; git status -u --porcelain | head -30"),
|
|
)
|
|
c.close()
|
|
print("DONE")
|