douyinWEB/scripts/_upload_and_restart.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

42 lines
1.3 KiB
Python

import paramiko, time
HOST = "107.173.30.245"
USER = "root"
PASSWORD = "Xiao4669805"
REPO = "/opt/douyinWEB"
LOCAL = "C:/Users/admin/Desktop/douyinWEB"
FILES = [
("backend/app/db.py", f"{REPO}/backend/app/db.py"),
("backend/app/main.py", f"{REPO}/backend/app/main.py"),
]
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)
sftp = c.open_sftp()
for local_rel, remote_path in FILES:
local_path = f"{LOCAL}/{local_rel}"
print(f"uploading {local_rel} -> {remote_path}")
sftp.put(local_path, remote_path)
sftp.close()
# verify the change is there
_s, out, _ = c.exec_command(f"grep -n 'platform.*douyin\\|platform: str' {REPO}/backend/app/db.py | head -5", timeout=15)
print("db.py check:", out.read().decode().strip())
_s, out, _ = c.exec_command(f"grep -n 'platform.*str' {REPO}/backend/app/main.py | grep sessions_active", timeout=15)
print("main.py check:", out.read().decode().strip())
# restart API
print("restarting API...")
c.exec_command("systemctl restart douyinweb-api >/dev/null 2>&1", timeout=5)
time.sleep(7)
_s, out, _ = c.exec_command("systemctl is-active douyinweb-api", timeout=15)
print("api:", out.read().decode().strip())
c.close()
print("DONE")