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

60 lines
2.2 KiB
Python

# -*- coding: utf-8 -*-
"""Finish downloads deploy: build web if needed, publish S3 assets."""
import sys
import time
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
REPO = "/opt/douyinWEB"
PY = f"{REPO}/backend/.venv/bin/python"
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False)
def run(cmd, timeout=600):
_, o, e = c.exec_command(cmd, timeout=timeout)
out = o.read().decode("utf-8", "replace")
err = e.read().decode("utf-8", "replace")
return (out + err).strip()
print("[pull]", run(f"cd {REPO} && git pull --ff-only origin test1 && git log --oneline -1"))
print("[backup]", run(f"cp -a {REPO}/backend/data/monitor.db /tmp/monitor.db.bak_dl_{int(time.time())}"))
# restart api to load new routes if needed
print("[api]", run("systemctl restart douyinweb-api; sleep 7; systemctl is-active douyinweb-api"))
print("[npm build]")
build = run(f"cd {REPO}/frontend && npm run build", timeout=360)
for line in build.splitlines()[-30:]:
print(line.encode("ascii", "replace").decode("ascii"))
print("[web]", run("systemctl restart douyinweb-web; sleep 4; systemctl is-active douyinweb-web"))
print("[publish S3]")
pub = run(
"export DY_S3_ENABLED=true "
"DY_S3_ENDPOINT=http://127.0.0.1:8333 "
"DY_S3_PUBLIC_BASE=https://s3.nomadro.com "
"DY_S3_ACCESS_KEY=douyin "
"DY_S3_SECRET_KEY=douyinweb_s3_2026 "
"DY_S3_BUCKET=douyin-covers "
"DY_S3_REGION=us-east-1; "
f"cd {REPO} && {PY} scripts/_publish_downloads.py",
timeout=900,
)
for line in pub.splitlines()[-60:]:
print(line.encode("ascii", "replace").decode("ascii"))
print("[verify head chrome]")
print(run("curl -sI 'https://s3.nomadro.com/douyin-covers/downloads/chrome/ChromeStandaloneSetup64.exe' | head -15"))
print("[verify head ext]")
print(run("curl -sI 'https://s3.nomadro.com/douyin-covers/downloads/extension/dylive-helper-latest.zip' | head -15"))
print("[services]", run("systemctl is-active douyinweb-api douyinweb-web"))
print("[db]", run(f"stat -c '%n %s' {REPO}/backend/data/monitor.db"))
c.close()
print("DONE")