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>
62 lines
1.8 KiB
Python
62 lines
1.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Deploy x-post fetch fix + republish extension 2.2.1."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
HOST = "107.173.30.245"
|
|
USER = "root"
|
|
PASSWORD = "Xiao4669805"
|
|
REPO = "/opt/douyinWEB"
|
|
|
|
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)
|
|
|
|
|
|
def run(cmd: str, timeout: int = 420) -> str:
|
|
_, out, err = c.exec_command(cmd, timeout=timeout)
|
|
return (out.read() + err.read()).decode("utf-8", "replace").strip()
|
|
|
|
|
|
print("[git]")
|
|
print(
|
|
run(
|
|
f"cd {REPO} && git fetch origin test1 && git pull --ff-only origin test1 && "
|
|
"git log -1 --format='%h %s' | tr -cd '\\11\\12\\15\\40-\\176'"
|
|
)
|
|
)
|
|
print("[backup db]")
|
|
print(run(f"cp -a {REPO}/backend/data/monitor.db /tmp/monitor.db.bak_xpostfix_$(date +%s) && echo bak_ok"))
|
|
print("[restart api]")
|
|
c.exec_command("systemctl restart douyinweb-api >/dev/null 2>&1", timeout=5)
|
|
time.sleep(8)
|
|
print("api:", run("systemctl is-active douyinweb-api"))
|
|
print("[publish ext]")
|
|
print(
|
|
run(
|
|
f"cd {REPO}/backend && set -a && "
|
|
f"[ -f {REPO}/backend/.env ] && . {REPO}/backend/.env; "
|
|
f"[ -f /etc/douyinweb.env ] && . /etc/douyinweb.env; "
|
|
"set +a; "
|
|
f"{REPO}/backend/.venv/bin/python {REPO}/scripts/_publish_downloads.py --ext-only "
|
|
"2>&1 | tr -cd '\\11\\12\\15\\40-\\176' | tail -n 40",
|
|
timeout=420,
|
|
)
|
|
)
|
|
print("[probe latest zip]")
|
|
print(
|
|
run(
|
|
"curl -sSI -m 15 https://s3.nomadro.com/douyin-covers/downloads/extension/dylive-helper-latest.zip "
|
|
"| tr -cd '\\11\\12\\15\\40-\\176' | head -n 15"
|
|
)
|
|
)
|
|
print("db:", run(f"stat -c '%n %s' {REPO}/backend/data/monitor.db"))
|
|
c.close()
|
|
print("DONE")
|