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>
63 lines
2.4 KiB
Python
63 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Deploy relay quality presets + switch VPS to vps_ultra."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
import paramiko
|
|
|
|
if hasattr(sys.stdout, "reconfigure"):
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
HOST = "108.174.50.68"
|
|
USER = "root"
|
|
PASS = "Xiao4669805"
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
FILES = [
|
|
("backend/app/youtube_relay_presets.py", "/opt/douyinWEB/backend/app/youtube_relay_presets.py"),
|
|
("backend/app/youtube_relay.py", "/opt/douyinWEB/backend/app/youtube_relay.py"),
|
|
("backend/app/youtube_relay_pipeline.py", "/opt/douyinWEB/backend/app/youtube_relay_pipeline.py"),
|
|
("backend/app/db.py", "/opt/douyinWEB/backend/app/db.py"),
|
|
("backend/app/main.py", "/opt/douyinWEB/backend/app/main.py"),
|
|
("backend/tests/test_youtube_relay_presets.py", "/opt/douyinWEB/backend/tests/test_youtube_relay_presets.py"),
|
|
("frontend/src/components/YtAssignPanel.tsx", "/opt/douyinWEB/frontend/src/components/YtAssignPanel.tsx"),
|
|
]
|
|
|
|
|
|
def run(c: paramiko.SSHClient, cmd: str, timeout: int = 300) -> str:
|
|
_, out, err = c.exec_command(cmd, timeout=timeout)
|
|
text = out.read().decode("utf-8", "replace")
|
|
e = err.read().decode("utf-8", "replace").strip()
|
|
if e:
|
|
text += ("\nERR: " + e) if text else ("ERR: " + e)
|
|
return text.strip()
|
|
|
|
|
|
def main() -> None:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, 22, USER, PASS, timeout=45, allow_agent=False, look_for_keys=False)
|
|
sftp = c.open_sftp()
|
|
for local_rel, remote in FILES:
|
|
local = ROOT / local_rel
|
|
print(f"upload {local_rel}")
|
|
sftp.put(str(local), remote)
|
|
sftp.close()
|
|
|
|
print(run(c, "cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'\nfrom app import db\ndb.update_settings_map({'youtube_relay_quality_preset': 'vps_ultra'})\nprint('db preset -> vps_ultra')\nPY", timeout=60))
|
|
c.exec_command("systemctl restart douyinweb-api", timeout=5)
|
|
time.sleep(4)
|
|
print("api:", run(c, "systemctl is-active douyinweb-api"))
|
|
print(run(c, "cd /opt/douyinWEB/frontend && npm run build 2>&1 | tail -12", timeout=600))
|
|
print(run(c, "systemctl restart douyinweb-web", timeout=30))
|
|
time.sleep(3)
|
|
print("web:", run(c, "systemctl is-active douyinweb-web"))
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|