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
1.6 KiB
Python
55 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Deploy Studio cookie monetize fix."""
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
REPO = "/opt/douyinWEB"
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
FILES = [
|
|
"backend/app/yt_studio_auth.py",
|
|
"backend/app/yt_long_monetize.py",
|
|
"backend/app/yt_long_pipeline.py",
|
|
"backend/app/main.py",
|
|
"backend/app/models.py",
|
|
"backend/app/db.py",
|
|
"frontend/src/app/settings/page.tsx",
|
|
]
|
|
|
|
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: 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[-4000:] if len(out) > 4000 else out, flush=True)
|
|
return out
|
|
|
|
|
|
sftp = c.open_sftp()
|
|
for rel in FILES:
|
|
local = ROOT / rel.replace("/", "\\") if "\\" in str(ROOT) else ROOT / rel
|
|
remote = f"{REPO}/{rel.replace(chr(92), '/')}"
|
|
print("[upload]", rel)
|
|
sftp.put(str(local), remote)
|
|
sftp.close()
|
|
|
|
run("systemctl restart douyinweb-api")
|
|
for _ in range(30):
|
|
if run("systemctl is-active douyinweb-api", timeout=15) == "active":
|
|
break
|
|
time.sleep(2)
|
|
|
|
print("[build]")
|
|
run(f"cd {REPO}/frontend && npm run build 2>&1 | tail -n 20", timeout=600)
|
|
run("systemctl restart douyinweb-web")
|
|
time.sleep(2)
|
|
print("[svc]", run("systemctl is-active douyinweb-api douyinweb-web"))
|
|
c.close()
|
|
print("DONE")
|