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>
55 lines
2.4 KiB
Python
55 lines
2.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Finish frontend build + extension S3 publish for X media feature."""
|
|
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)
|
|
return (o.read() + e.read()).decode("utf-8", "replace").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_xmedia_{int(time.time())}"))
|
|
print("[api restart]", run("systemctl restart douyinweb-api; sleep 7; systemctl is-active douyinweb-api"))
|
|
|
|
print("[npm build]")
|
|
b = run(f"cd {REPO}/frontend && npm run build", timeout=360)
|
|
for line in b.splitlines()[-22:]:
|
|
print(line.encode("ascii", "replace").decode("ascii"))
|
|
|
|
print("[web]", run("systemctl restart douyinweb-web; sleep 4; systemctl is-active douyinweb-web"))
|
|
|
|
print("[publish ext]")
|
|
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 --ext-only",
|
|
timeout=600,
|
|
)
|
|
for line in pub.splitlines()[-25:]:
|
|
print(line.encode("ascii", "replace").decode("ascii"))
|
|
|
|
print("[verify]")
|
|
print("api:", run("systemctl is-active douyinweb-api"))
|
|
print("web:", run("systemctl is-active douyinweb-web"))
|
|
print("ext head:", run("curl -sI 'https://s3.nomadro.com/douyin-covers/downloads/extension/dylive-helper-latest.zip' | head -12"))
|
|
print("meta:", 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; "
|
|
f"cd {REPO}/backend && {PY} -c \"from app.downloads import catalog; import json; print(json.dumps([i for i in catalog()['items'] if i['id']=='dylive-helper'], ensure_ascii=False))\""
|
|
))
|
|
print("[db]", run(f"stat -c '%n %s' {REPO}/backend/data/monitor.db"))
|
|
c.close()
|
|
print("DONE")
|