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

63 lines
1.6 KiB
Python

# -*- coding: utf-8 -*-
"""Hide Netdata UI — deploy ops page only."""
from __future__ import annotations
import sys
import time
from pathlib import Path
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
HOST = "108.174.50.68"
ROOT = Path(__file__).resolve().parents[1]
APP = "/opt/douyinWEB"
FILE = "frontend/src/app/ops/page.tsx"
REMOTE = """#!/usr/bin/env bash
set -euo pipefail
cd /opt/douyinWEB/frontend
npm run build 2>&1 | tail -10
systemctl restart douyinweb-web
sleep 2
systemctl is-active douyinweb-web
echo DONE
"""
def main() -> None:
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(HOST, 22, "root", "Xiao4669805", timeout=60, allow_agent=False, look_for_keys=False)
sftp = c.open_sftp()
print("upload", FILE)
sftp.put(str(ROOT / FILE), f"{APP}/{FILE.replace(chr(92), '/')}")
with sftp.file("/tmp/deploy_ops_hide_netdata.sh", "w") as f:
f.write(REMOTE)
sftp.chmod("/tmp/deploy_ops_hide_netdata.sh", 0o755)
sftp.close()
chan = c.get_transport().open_session()
chan.settimeout(300)
chan.exec_command("bash /tmp/deploy_ops_hide_netdata.sh")
out = b""
deadline = time.time() + 280
while time.time() < deadline:
if chan.recv_ready():
out += chan.recv(8192)
elif chan.exit_status_ready():
while chan.recv_ready():
out += chan.recv(8192)
break
else:
time.sleep(0.5)
print(out.decode("utf-8", "replace")[-4000:])
if chan.exit_status_ready():
print("exit", chan.recv_exit_status())
c.close()
if __name__ == "__main__":
main()