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>
78 lines
2.7 KiB
Python
78 lines
2.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Deploy yt-long live sampling fix; preserve enabled state; trigger sample."""
|
|
import sys
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
HOST = "107.173.30.245"
|
|
REPO = "/opt/douyinWEB"
|
|
|
|
|
|
def main() -> None:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False)
|
|
|
|
def run(cmd: str, timeout: int = 600) -> str:
|
|
_, o, e = c.exec_command(cmd, timeout=timeout)
|
|
out = (o.read() + e.read()).decode("utf-8", "replace").strip()
|
|
print(out[-5000:] if len(out) > 5000 else out, flush=True)
|
|
return out
|
|
|
|
db = f"{REPO}/backend/data/monitor.db"
|
|
before = run(f"stat -c '%s' {db}")
|
|
print("[db before]", before)
|
|
print("[status]")
|
|
run(f"cd {REPO} && git status -sb && git rev-parse --short HEAD")
|
|
print("[stash]")
|
|
run(f"cd {REPO} && git stash push -u -m auto-yt-long-sample-9732647 || true")
|
|
print("[pull]")
|
|
run(f"cd {REPO} && git fetch origin test1 && git pull --ff-only origin test1 && git log --oneline -1")
|
|
print("[api restart]")
|
|
run("systemctl restart douyinweb-api")
|
|
for _ in range(40):
|
|
if run("systemctl is-active douyinweb-api", timeout=15) == "active":
|
|
print("[api] active")
|
|
break
|
|
time.sleep(2)
|
|
|
|
print("[verify+sample]")
|
|
run(
|
|
r"""cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'
|
|
from app import db, yt_long_db
|
|
from app.yt_long_pipeline import yt_long_pipeline, sample_live_now
|
|
db.init_db()
|
|
cfg = db.get_settings_map()
|
|
print('enabled', cfg.get('yt_long_enabled'))
|
|
print('live_sample', cfg.get('yt_long_live_sample'))
|
|
print('channels', len(yt_long_db.list_yt_long_channels()))
|
|
print('jobs_before', len(yt_long_db.list_yt_long_jobs(limit=50)))
|
|
r = sample_live_now()
|
|
print('sample', r)
|
|
print('jobs_after', len(yt_long_db.list_yt_long_jobs(limit=50)))
|
|
st = yt_long_pipeline.status()
|
|
print('status', {k: st.get(k) for k in ['enabled','running','quota_used','quota_gap','douyin_live_count','last_error']})
|
|
PY"""
|
|
)
|
|
|
|
print("[build]")
|
|
run(f"cd {REPO}/frontend && npm run build 2>&1 | tail -n 30", timeout=600)
|
|
run("systemctl restart douyinweb-web")
|
|
time.sleep(2)
|
|
after = run(f"stat -c '%s' {db}")
|
|
print("[db after]", after)
|
|
print("[svc]", run("systemctl is-active douyinweb-api douyinweb-web"))
|
|
print("[curl sample]")
|
|
run("curl -sS -m 90 -X POST http://127.0.0.1:8787/api/yt-long/sample-now")
|
|
print("[curl jobs]")
|
|
run('curl -sS -m 20 "http://127.0.0.1:8787/api/yt-long/jobs?limit=5"')
|
|
c.close()
|
|
print("DONE")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|