# -*- coding: utf-8 -*- import sys, time, paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") REPO = "/opt/douyinWEB" 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, timeout=600): _, o, e = c.exec_command(cmd, timeout=timeout) out = (o.read() + e.read()).decode("utf-8", "replace").strip() print(out[-4000:] if len(out) > 4000 else out, flush=True) return out print("[pull]", run(f"cd {REPO} && git stash push -u -m auto-yt-long-ui || true; git pull --ff-only origin test1 && git log --oneline -1")) print("[build]", run(f"cd {REPO}/frontend && npm run build 2>&1 | tail -n 20", timeout=600)) run("systemctl restart douyinweb-web") time.sleep(2) print("[svc]", run("systemctl is-active douyinweb-web")) c.close() print("DONE")