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>
85 lines
2.3 KiB
Python
85 lines
2.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Deploy round-4 response speed opts."""
|
|
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/main.py",
|
|
"backend/app/yt_long_pipeline.py",
|
|
"backend/app/youtube_live.py",
|
|
"frontend/src/components/GlobalEventAlerts.tsx",
|
|
"frontend/src/app/page.tsx",
|
|
"frontend/src/app/yt-long/page.tsx",
|
|
"frontend/src/app/tiktok/page.tsx",
|
|
"frontend/src/app/ops/mobile/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
|
|
from app.db import init_db
|
|
from app.yt_long_pipeline import yt_long_pipeline as ylp
|
|
from app.tiktok_pipeline import tiktok_pipeline as tp
|
|
|
|
init_db()
|
|
|
|
t0=time.perf_counter(); yl=ylp.status_light(); t1=time.perf_counter()
|
|
print(f"yt_long_light_ms={(t1-t0)*1000:.1f} light={yl.get('light')}")
|
|
|
|
t0=time.perf_counter(); tk=tp.status(); t1=time.perf_counter()
|
|
print(f"tiktok_core_ms={(t1-t0)*1000:.1f}")
|
|
|
|
from app.main import settings_notify_flags
|
|
import asyncio
|
|
t0=time.perf_counter()
|
|
flags=asyncio.get_event_loop().run_until_complete(settings_notify_flags())
|
|
t1=time.perf_counter()
|
|
print(f"notify_flags_ms={(t1-t0)*1000:.1f} keys={len(flags)}")
|
|
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[-3500:] if len(out) > 3500 else out)
|
|
if err.strip():
|
|
print("STDERR:", err[-1500:])
|
|
print("exit", code)
|
|
c.close()
|
|
return code
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|