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>
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Frontend-only deploy for EnableSwitch UI. Does not touch DB or backend."""
|
|
import paramiko
|
|
import time
|
|
import sys
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
HOST = "107.173.30.245"
|
|
USER = "root"
|
|
PASSWORD = "Xiao4669805"
|
|
REPO = "/opt/douyinWEB"
|
|
LOCAL = "C:/Users/admin/Desktop/douyinWEB"
|
|
|
|
FILES = [
|
|
"frontend/src/components/EnableSwitch.tsx",
|
|
"frontend/src/app/shorts/page.tsx",
|
|
"frontend/src/app/yt-long/page.tsx",
|
|
"frontend/src/app/tiktok/page.tsx",
|
|
"frontend/src/app/x/page.tsx",
|
|
]
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, 22, USER, PASSWORD, timeout=30, allow_agent=False, look_for_keys=False)
|
|
|
|
sftp = c.open_sftp()
|
|
for rel in FILES:
|
|
print("upload", rel)
|
|
sftp.put(f"{LOCAL}/{rel}", f"{REPO}/{rel}")
|
|
sftp.close()
|
|
|
|
print("[npm build]")
|
|
_, out, _ = c.exec_command(f"cd {REPO}/frontend && npm run build 2>&1 | tail -12", timeout=360)
|
|
print(out.read().decode("utf-8", "replace").encode("ascii", "replace").decode())
|
|
|
|
print("[restart web only]")
|
|
c.exec_command("systemctl restart douyinweb-web >/dev/null 2>&1", timeout=5)
|
|
time.sleep(6)
|
|
_, o, _ = c.exec_command("systemctl is-active douyinweb-web douyinweb-api", timeout=15)
|
|
print("services:", o.read().decode().strip())
|
|
|
|
# confirm api still healthy and db untouched
|
|
_, o, _ = c.exec_command(
|
|
"curl -sS -m 6 http://127.0.0.1:8014/api/health | python3 -c \"import sys,json; d=json.load(sys.stdin); print('api_ok', d.get('ok'), 'rooms', d.get('monitor',{}).get('room_count'), 'shorts_ch', (d.get('shorts',{}).get('stats') or {}).get('enabled_channels'))\"",
|
|
timeout=20,
|
|
)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
c.close()
|
|
print("DONE")
|