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>
59 lines
1.7 KiB
Python
59 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
import sys
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
HOST = "107.173.30.245"
|
|
REPO = "/opt/douyinWEB"
|
|
VENV = f"{REPO}/backend/.venv/bin/python"
|
|
|
|
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 = 120) -> str:
|
|
print("$", cmd[:180])
|
|
_s, out, err = c.exec_command(cmd, timeout=timeout)
|
|
o = out.read().decode("utf-8", "replace").strip()
|
|
e = err.read().decode("utf-8", "replace").strip()
|
|
if o:
|
|
print(o)
|
|
if e:
|
|
print("ERR:", e[:800])
|
|
return o
|
|
|
|
|
|
time.sleep(3)
|
|
print("=== services ===")
|
|
run("systemctl is-active douyinweb-api douyinweb-web")
|
|
|
|
print("\n=== api logs if down ===")
|
|
if "active" not in run("systemctl is-active douyinweb-api"):
|
|
run("journalctl -u douyinweb-api -n 40 --no-pager")
|
|
|
|
print("\n=== health ===")
|
|
run("curl -sS http://127.0.0.1:8014/api/health")
|
|
run("curl -sS http://127.0.0.1:8014/api/monitor/status | head -c 350")
|
|
run("curl -sS http://127.0.0.1:8014/api/shorts/status | head -c 350")
|
|
run("curl -sS http://127.0.0.1:8014/api/tiktok/setup | head -c 450")
|
|
|
|
print("\n=== tiktok_enabled ===")
|
|
run(
|
|
f"cd {REPO}/backend && {VENV} -c "
|
|
"'from app import db; print(db.get_settings_map().get(\"tiktok_enabled\"))'"
|
|
)
|
|
|
|
print("\n=== finish web if needed ===")
|
|
if "active" not in run("systemctl is-active douyinweb-web"):
|
|
run(f"cd {REPO}/frontend && npm run build 2>&1 | tail -5", timeout=420)
|
|
c.exec_command("systemctl restart douyinweb-web", timeout=5)
|
|
time.sleep(8)
|
|
run("systemctl is-active douyinweb-web")
|
|
|
|
c.close()
|
|
print("DONE")
|