Ship zombie reconcile, S3 covers, session end/drill-down, rooms ops, and refresh README for production. Co-authored-by: Cursor <cursoragent@cursor.com>
86 lines
2.8 KiB
Python
86 lines
2.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Deploy modal fix + slots/anchors/shell upgrades."""
|
|
import time
|
|
from pathlib import Path
|
|
|
|
import paramiko
|
|
|
|
HOST = "107.173.30.245"
|
|
USER = "root"
|
|
PASSWORD = "Xiao4669805"
|
|
REMOTE = "/opt/douyinWEB"
|
|
LOCAL = Path(__file__).resolve().parents[1]
|
|
|
|
FILES = [
|
|
"frontend/src/components/Modal.tsx",
|
|
"frontend/src/components/SessionDetailModal.tsx",
|
|
"frontend/src/components/ImageLightbox.tsx",
|
|
"frontend/src/components/Shell.tsx",
|
|
"frontend/src/app/slots/page.tsx",
|
|
"frontend/src/app/sessions/page.tsx",
|
|
"frontend/src/app/anchors/page.tsx",
|
|
"frontend/src/app/page.tsx",
|
|
"frontend/src/app/globals.css",
|
|
"backend/app/main.py",
|
|
"backend/app/stats.py",
|
|
"backend/app/db.py",
|
|
"backend/app/monitor.py",
|
|
]
|
|
|
|
|
|
def run(c, cmd: str, timeout: int = 300) -> tuple[int, str]:
|
|
print("$", cmd, flush=True)
|
|
chan = c.get_transport().open_session()
|
|
chan.settimeout(timeout)
|
|
chan.get_pty()
|
|
chan.exec_command(cmd)
|
|
buf: list[str] = []
|
|
while True:
|
|
if chan.recv_ready():
|
|
buf.append(chan.recv(65535).decode("utf-8", "replace"))
|
|
if chan.exit_status_ready() and not chan.recv_ready():
|
|
break
|
|
time.sleep(0.25)
|
|
while chan.recv_ready():
|
|
buf.append(chan.recv(65535).decode("utf-8", "replace"))
|
|
code = chan.recv_exit_status()
|
|
out = "".join(buf)
|
|
print(out[-3000:], flush=True)
|
|
return code, out
|
|
|
|
|
|
def main() -> None:
|
|
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 rel in FILES:
|
|
local = LOCAL / rel
|
|
if not local.exists():
|
|
print("skip missing", rel, flush=True)
|
|
continue
|
|
remote = f"{REMOTE}/{rel}"
|
|
parent = "/".join(remote.split("/")[:-1])
|
|
run(c, f"mkdir -p {parent}", timeout=30)
|
|
print("upload", rel, flush=True)
|
|
sftp.put(str(local), remote)
|
|
sftp.close()
|
|
|
|
run(c, "systemctl restart douyinweb-api --no-block; sleep 3; systemctl is-active douyinweb-api")
|
|
code, _ = run(c, "cd /opt/douyinWEB/frontend && npm run build", timeout=360)
|
|
if code != 0:
|
|
raise SystemExit("build failed")
|
|
run(c, "systemctl restart douyinweb-web --no-block; sleep 4; systemctl start douyinweb-api douyinweb-web; sleep 3; systemctl is-active douyinweb-api douyinweb-web")
|
|
run(
|
|
c,
|
|
"curl -s -o /dev/null -w 'api=%{http_code} ' http://127.0.0.1:8014/api/health; "
|
|
"curl -s -o /dev/null -w 'slots=%{http_code} ' http://127.0.0.1:4015/slots; "
|
|
"curl -s -o /dev/null -w 'anchors=%{http_code}\\n' http://127.0.0.1:4015/anchors",
|
|
)
|
|
c.close()
|
|
print("deployed ok", flush=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|