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")