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>
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
import sys
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
HOST = "107.173.30.245"
|
|
USER = "root"
|
|
PASSWORD = "Xiao4669805"
|
|
|
|
|
|
def run(client: paramiko.SSHClient, cmd: str, timeout: int = 900) -> int:
|
|
chan = client.get_transport().open_session()
|
|
chan.settimeout(timeout)
|
|
chan.get_pty()
|
|
chan.exec_command(cmd)
|
|
chunks: list[str] = []
|
|
while True:
|
|
if chan.recv_ready():
|
|
chunks.append(chan.recv(65535).decode("utf-8", "replace"))
|
|
if chan.exit_status_ready() and not chan.recv_ready():
|
|
break
|
|
time.sleep(0.25)
|
|
if chan.recv_stderr_ready():
|
|
chunks.append(chan.recv_stderr(65535).decode("utf-8", "replace"))
|
|
output = "".join(chunks)
|
|
print(output[-4000:], flush=True)
|
|
return chan.recv_exit_status()
|
|
|
|
|
|
def main() -> int:
|
|
client = paramiko.SSHClient()
|
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
client.connect(HOST, 22, USER, PASSWORD, timeout=30, allow_agent=False, look_for_keys=False)
|
|
try:
|
|
code = run(
|
|
client,
|
|
"cd /opt/douyinWEB && "
|
|
"git stash push -u -m 'auto-stash-before-pull-2026-08-11' || true && "
|
|
"git pull --ff-only origin main && "
|
|
"cd frontend && npm run build && "
|
|
"systemctl restart douyinweb-web --no-block && "
|
|
"systemctl restart douyinweb-api --no-block && "
|
|
"sleep 10; "
|
|
"systemctl is-active douyinweb-web; "
|
|
"systemctl is-active douyinweb-api; "
|
|
"grep -n '素材' /opt/douyinWEB/frontend/src/app/shorts/page.tsx | head -3",
|
|
)
|
|
return code
|
|
finally:
|
|
client.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|