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>
99 lines
3.1 KiB
Python
99 lines
3.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Deploy round-3 response speed opts; measure on VPS."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
HOST = "108.174.50.68"
|
|
PASS = "Xiao4669805"
|
|
REPO = "/opt/douyinWEB"
|
|
|
|
FILES = [
|
|
"backend/app/yt_long_pipeline.py",
|
|
"backend/app/yt_assign_db.py",
|
|
"backend/app/shorts_pipeline.py",
|
|
"backend/app/tiktok_pipeline.py",
|
|
"backend/app/main.py",
|
|
"frontend/src/lib/realtime.ts",
|
|
"frontend/src/app/page.tsx",
|
|
"frontend/src/app/shorts/page.tsx",
|
|
"frontend/src/app/tiktok/page.tsx",
|
|
"frontend/src/app/yt-long/page.tsx",
|
|
"frontend/src/app/x/page.tsx",
|
|
]
|
|
|
|
|
|
def main() -> int:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, 22, "root", PASS, timeout=60, allow_agent=False, look_for_keys=False)
|
|
sftp = c.open_sftp()
|
|
for rel in FILES:
|
|
sftp.put(str(ROOT / rel), f"{REPO}/{rel}")
|
|
print("uploaded", rel)
|
|
sftp.close()
|
|
|
|
cmd = r"""
|
|
set -e
|
|
systemctl restart douyinweb-api
|
|
cd /opt/douyinWEB/frontend && npm run build
|
|
systemctl restart douyinweb-web
|
|
sleep 3
|
|
systemctl is-active douyinweb-api douyinweb-web
|
|
|
|
cd /opt/douyinWEB/backend
|
|
.venv/bin/python - <<'PY'
|
|
import time, json
|
|
from app.db import init_db
|
|
from app.yt_long_pipeline import yt_long_pipeline as ylp
|
|
from app.shorts_pipeline import shorts_pipeline as sp
|
|
from app.tiktok_pipeline import tiktok_pipeline as tp
|
|
from app import yt_assign_db
|
|
from app.monitor import monitor as mon
|
|
|
|
init_db()
|
|
|
|
t0=time.perf_counter(); a=ylp.status(); t1=time.perf_counter()
|
|
b=ylp.status(); t2=time.perf_counter()
|
|
print(f"yt_long_status_ms first={(t1-t0)*1000:.1f} cached={(t2-t1)*1000:.1f}")
|
|
|
|
t0=time.perf_counter(); sl=sp.status_light(); t1=time.perf_counter()
|
|
sl2=sp.status_light(); t2=time.perf_counter()
|
|
print(f"shorts_light_ms first={(t1-t0)*1000:.1f} cached={(t2-t1)*1000:.1f} light={sl.get('light')} has_board={'board' in sl}")
|
|
|
|
t0=time.perf_counter(); sf=sp.status(); t1=time.perf_counter()
|
|
print(f"shorts_full_ms first={(t1-t0)*1000:.1f}")
|
|
|
|
t0=time.perf_counter(); tk=tp.status(); t1=time.perf_counter()
|
|
tk2=tp.status(); t2=time.perf_counter()
|
|
print(f"tiktok_status_ms first={(t1-t0)*1000:.1f} cached={(t2-t1)*1000:.1f}")
|
|
|
|
t0=time.perf_counter(); g=yt_assign_db.list_groups(include_urls=True); t1=time.perf_counter()
|
|
print(f"assign_groups_readonly_ms={(t1-t0)*1000:.1f} n={len(g)}")
|
|
|
|
t0=time.perf_counter(); m=mon.status(light=True); t1=time.perf_counter()
|
|
print(f"monitor_light_ms={(t1-t0)*1000:.1f} live={m.get('live_count')}")
|
|
PY
|
|
"""
|
|
print("remote deploy…")
|
|
stdin, stdout, stderr = c.exec_command(cmd, timeout=360)
|
|
out = stdout.read().decode("utf-8", "replace")
|
|
err = stderr.read().decode("utf-8", "replace")
|
|
code = stdout.channel.recv_exit_status()
|
|
print(out[-4000:] if len(out) > 4000 else out)
|
|
if err.strip():
|
|
print("STDERR:", err[-2000:])
|
|
print("exit", code)
|
|
c.close()
|
|
return code
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|