# -*- coding: utf-8 -*- """Deploy frontend exclusive-live UI banner to VPS.""" from __future__ import annotations import sys from pathlib import Path import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") ROOT = Path(__file__).resolve().parents[1] HOST = "108.174.50.68" PASS = "Xiao4669805" REPO = "/opt/douyinWEB" def main() -> None: c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(HOST, 22, "root", PASS, timeout=60, allow_agent=False, look_for_keys=False) sftp = c.open_sftp() sftp.put( str(ROOT / "frontend/src/components/YtAssignPanel.tsx"), f"{REPO}/frontend/src/components/YtAssignPanel.tsx", ) sftp.close() cmd = f""" set -e cd {REPO}/frontend npm run build systemctl restart douyinweb-web sleep 2 systemctl is-active douyinweb-web grep -n exclusive_winner_group_id {REPO}/frontend/src/components/YtAssignPanel.tsx | head -1 """ _i, o, e = c.exec_command(cmd, timeout=600) print(o.read().decode("utf-8", "replace")) err = e.read().decode("utf-8", "replace") if err.strip(): print("ERR", err[-3000:]) c.close() if __name__ == "__main__": main()