douyinWEB/scripts/deploy_feature_pass.py
eric a360eec2ba Document slots/covers/PB ops UX and sync feature pass to main.
Ship zombie reconcile, S3 covers, session end/drill-down, rooms ops, and refresh README for production.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-08 20:07:15 -05:00

79 lines
2.5 KiB
Python

# -*- coding: utf-8 -*-
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/lib/api.js",
"frontend/src/components/SessionDetailModal.tsx",
"frontend/src/app/covers/page.tsx",
"frontend/src/app/settings/page.tsx",
"frontend/src/app/page.tsx",
"frontend/src/app/sessions/page.tsx",
"frontend/src/app/slots/page.tsx",
"frontend/src/app/anchors/page.tsx",
"backend/app/main.py",
"backend/app/db.py",
"backend/app/cover.py",
"backend/app/pb_sync.py",
"backend/app/monitor.py",
"backend/app/douyin.py",
]
def run(c, cmd, timeout=360):
print("$", cmd[:140], flush=True)
chan = c.get_transport().open_session()
chan.settimeout(timeout)
chan.get_pty()
chan.exec_command(cmd)
buf = []
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()
print("".join(buf)[-2200:], flush=True)
return code
def main():
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", rel)
continue
print("upload", rel, flush=True)
sftp.put(str(local), f"{REMOTE}/{rel}")
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(1)
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 http://127.0.0.1:8014/api/health | head -c 500; echo; "
"curl -s -o /dev/null -w 'home=%{http_code} settings=%{http_code} covers=%{http_code}\\n' "
"http://127.0.0.1:4015/ http://127.0.0.1:4015/settings http://127.0.0.1:4015/covers",
)
c.close()
print("DONE")
if __name__ == "__main__":
main()