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>
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
HOST, REPO = "107.173.30.245", "/opt/douyinWEB"
|
|
LOCAL = Path(r"C:/Users/admin/Desktop/douyinWEB")
|
|
FILES = [
|
|
"frontend/src/lib/shellNav.ts",
|
|
"frontend/src/app/web/page.tsx",
|
|
"frontend/src/app/ops/page.tsx",
|
|
]
|
|
|
|
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 = 600) -> str:
|
|
_, o, e = c.exec_command(cmd, timeout=timeout)
|
|
return (o.read() + e.read()).decode("utf-8", "replace").strip()
|
|
|
|
|
|
sftp = c.open_sftp()
|
|
for rel in FILES:
|
|
remote = f"{REPO}/{rel}"
|
|
run(f"mkdir -p {os.path.dirname(remote)}")
|
|
print("[upload]", rel)
|
|
sftp.put(str(LOCAL / rel), remote)
|
|
sftp.close()
|
|
print("[build]", run(f"cd {REPO}/frontend && npm run build 2>&1 | tail -20", timeout=600))
|
|
print("[web]", run("systemctl restart douyinweb-web; sleep 4; systemctl is-active douyinweb-web"))
|
|
print("[http]", run("curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:4015/web"))
|
|
c.close()
|
|
print("DONE")
|