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>
50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
import paramiko, time
|
|
|
|
HOST = "107.173.30.245"
|
|
USER = "root"
|
|
PASSWORD = "Xiao4669805"
|
|
REPO = "/opt/douyinWEB"
|
|
|
|
|
|
def run(c, 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
|
|
|
|
|
|
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)
|
|
|
|
print("[1] git log --oneline -3 (before)")
|
|
o, _ = run(c, f"cd {REPO} && git log --oneline -3")
|
|
print(o)
|
|
|
|
print("[2] git pull origin dev")
|
|
o, e = run(c, f"cd {REPO} && git pull origin dev 2>&1", timeout=60)
|
|
print(o or e)
|
|
|
|
print("[3] git log --oneline -3 (after)")
|
|
o, _ = run(c, f"cd {REPO} && git log --oneline -3")
|
|
print(o)
|
|
|
|
print("[4] restart API")
|
|
c.exec_command("systemctl restart douyinweb-api >/dev/null 2>&1", timeout=5)
|
|
time.sleep(5)
|
|
o, _ = run(c, "systemctl is-active douyinweb-api", timeout=15)
|
|
print("api:", o)
|
|
|
|
print("[5] npm run build")
|
|
o, _ = run(c, f"cd {REPO}/frontend && npm run build 2>&1 | tail -15", timeout=360)
|
|
print(o.encode("ascii", "replace").decode())
|
|
|
|
print("[6] restart web")
|
|
c.exec_command("systemctl restart douyinweb-web >/dev/null 2>&1", timeout=5)
|
|
time.sleep(4)
|
|
o, _ = run(c, "systemctl is-active douyinweb-web", timeout=15)
|
|
print("web:", o)
|
|
|
|
c.close()
|
|
print("DONE")
|