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>
66 lines
1.9 KiB
Python
66 lines
1.9 KiB
Python
import paramiko
|
|
import sys
|
|
import time
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(
|
|
"107.173.30.245",
|
|
22,
|
|
"root",
|
|
"Xiao4669805",
|
|
timeout=30,
|
|
allow_agent=False,
|
|
look_for_keys=False,
|
|
)
|
|
|
|
|
|
def run(cmd: str, t: int = 120) -> str:
|
|
_, o, e = c.exec_command(cmd, timeout=t)
|
|
return (o.read() + e.read()).decode("utf-8", "replace")
|
|
|
|
|
|
print("=== LOG TAIL ===")
|
|
print(run("tail -n 100 /tmp/dylive_deploy.log 2>/dev/null || echo NO_LOG"))
|
|
print("=== GIT ===")
|
|
print(run("cd /opt/douyinWEB && git log --oneline -3 && git rev-parse --short HEAD && git status -sb"))
|
|
print("=== SVC ===")
|
|
print(run("systemctl is-active douyinweb-api; systemctl is-active douyinweb-web"))
|
|
print("=== CODE CHECK ===")
|
|
print(run("grep -n create_web_job /opt/douyinWEB/backend/app/x2_db.py | head -3"))
|
|
print(run("grep -n X.Ops /opt/douyinWEB/frontend/src/app/x/page.tsx | head -3"))
|
|
|
|
head = run("cd /opt/douyinWEB && git rev-parse --short HEAD").strip()
|
|
print("=== NEED PULL ===")
|
|
print(
|
|
run(
|
|
"cd /opt/douyinWEB && GIT_TERMINAL_PROMPT=0 git pull origin dev && git log --oneline -2",
|
|
t=180,
|
|
)
|
|
)
|
|
print("code:", run("cd /opt/douyinWEB && git rev-parse --short HEAD").strip())
|
|
|
|
# ensure build + restart
|
|
print("=== RESTART API ===")
|
|
run("systemctl restart douyinweb-api")
|
|
time.sleep(6)
|
|
print(run("systemctl is-active douyinweb-api"))
|
|
|
|
print("=== NPM BUILD ===")
|
|
# write build to log file to avoid unicode console issues
|
|
run(
|
|
"cd /opt/douyinWEB/frontend && npm run build > /tmp/dylive_fe_build.log 2>&1; echo EXIT:$? >> /tmp/dylive_fe_build.log",
|
|
t=420,
|
|
)
|
|
print(run("tail -n 25 /tmp/dylive_fe_build.log"))
|
|
|
|
print("=== RESTART WEB ===")
|
|
run("systemctl restart douyinweb-web")
|
|
time.sleep(5)
|
|
print(run("systemctl is-active douyinweb-api; systemctl is-active douyinweb-web"))
|
|
print(run("cd /opt/douyinWEB && git log --oneline -1"))
|
|
print("DEPLOY_DONE")
|
|
c.close()
|