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>
54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
HOST = "107.173.30.245"
|
|
USER = "root"
|
|
PASSWORD = "Xiao4669805"
|
|
REMOTE = "/opt/douyinWEB"
|
|
LOCAL = Path(__file__).resolve().parents[1]
|
|
FILES = [
|
|
"frontend/src/app/page.tsx",
|
|
"frontend/src/app/shorts/page.tsx",
|
|
]
|
|
|
|
|
|
def run(c, cmd, timeout=600):
|
|
chan = c.get_transport().open_session()
|
|
chan.settimeout(timeout)
|
|
chan.get_pty()
|
|
chan.exec_command(cmd)
|
|
buf = []
|
|
while True:
|
|
if chan.recv_ready():
|
|
buf.append(chan.recv(65535).decode("utf-8", "replace"))
|
|
if chan.exit_status_ready() and not chan.recv_ready():
|
|
break
|
|
time.sleep(0.25)
|
|
code = chan.recv_exit_status()
|
|
text = "".join(buf)
|
|
clean = "".join(ch for ch in text if ord(ch) < 128 or "\u4e00" <= ch <= "\u9fff")
|
|
print(clean[-2000:], flush=True)
|
|
return code
|
|
|
|
|
|
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, flush=True)
|
|
sftp.put(str(LOCAL / rel), f"{REMOTE}/{rel}")
|
|
sftp.close()
|
|
run(c, "grep -n '素材' /opt/douyinWEB/frontend/src/app/shorts/page.tsx | head -3", timeout=30)
|
|
code = run(c, "cd /opt/douyinWEB/frontend && npm run build", timeout=600)
|
|
if code != 0:
|
|
raise SystemExit(code)
|
|
run(c, "systemctl restart douyinweb-web --no-block; sleep 3; systemctl is-active douyinweb-web")
|
|
run(c, "grep -r '素材' /opt/douyinWEB/frontend/.next/server/app/shorts 2>/dev/null | head -2 || echo 'check built chunks manually'", timeout=30)
|
|
c.close()
|
|
print("DONE")
|