douyinWEB/scripts/_restart_and_build.py
eric d409e416da Ship physical dual-edge stack, Studio CDP live metrics, and ops tooling.
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>
2026-09-04 22:42:40 -05:00

39 lines
1.1 KiB
Python

import paramiko, time
HOST = "107.173.30.245"
USER = "root"
PASSWORD = "Xiao4669805"
REPO = "/opt/douyinWEB"
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)
def run(cmd, timeout=300):
_s, out, err = c.exec_command(cmd, timeout=timeout)
o = out.read().decode("utf-8", "replace").strip()
e = err.read().decode("utf-8", "replace").strip()
return o, e
# restart API
print("[restart api]")
c.exec_command("systemctl restart douyinweb-api >/dev/null 2>&1", timeout=5)
time.sleep(6)
o, _ = run("systemctl is-active douyinweb-api", timeout=15)
print("api:", o)
# build frontend
print("[npm build]")
o, _ = run(f"cd {REPO}/frontend && npm run build 2>&1 | tail -10", timeout=360)
print(o.encode("ascii", "replace").decode())
# restart web
print("[restart web]")
c.exec_command("systemctl restart douyinweb-web >/dev/null 2>&1", timeout=5)
time.sleep(4)
o, _ = run("systemctl is-active douyinweb-web", timeout=15)
print("web:", o)
c.close()
print("DONE")