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>
64 lines
2.1 KiB
Python
64 lines
2.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Deploy YouTube Live focus fix to neko-3 and recreate container."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
HOST = "108.174.50.68"
|
|
PASS = "Xiao4669805"
|
|
FILES = [
|
|
"backend/neko/browser-launch.sh",
|
|
"backend/neko/live-ops-extension/background.js",
|
|
"backend/neko/live-ops-extension/content.js",
|
|
"backend/neko/live-ops-extension/manifest.json",
|
|
]
|
|
|
|
|
|
def main() -> None:
|
|
launch = ROOT / "backend/neko/browser-launch.sh"
|
|
launch.write_bytes(launch.read_bytes().replace(b"\r\n", b"\n").replace(b"\r", b"\n"))
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, 22, "root", PASS, timeout=60, allow_agent=False, look_for_keys=False)
|
|
sftp = c.open_sftp()
|
|
for rel in FILES:
|
|
sftp.put(str(ROOT / rel), f"/opt/douyinWEB/{rel.replace(chr(92), '/')}")
|
|
print("uploaded", rel)
|
|
sftp.close()
|
|
|
|
cmd = r"""
|
|
set -e
|
|
chmod +x /opt/douyinWEB/backend/neko/browser-launch.sh
|
|
sed -i 's/\r$//' /opt/douyinWEB/backend/neko/browser-launch.sh
|
|
cd /opt/douyinWEB/backend
|
|
.venv/bin/python - <<'PY'
|
|
from app import youtube_neko, yt_assign_db
|
|
groups = yt_assign_db.list_groups(include_urls=False)
|
|
desired = max([int(g.get("neko_instance_id") or 0) for g in groups] + [0])
|
|
youtube_neko._compose_path().write_text(youtube_neko._render_compose(desired), encoding="utf-8")
|
|
code, out = youtube_neko._run(youtube_neko._compose_cmd("up", "-d", "--force-recreate", "neko3"), timeout=600)
|
|
print("recreate", code, out[-300:])
|
|
PY
|
|
sleep 20
|
|
docker exec douyinweb-neko-3 grep -n focus_live_studio_tab_once /etc/neko/browser-launch.sh | head -1
|
|
docker exec douyinweb-neko-3 grep version /etc/neko/live-ops-extension/manifest.json | head -1
|
|
docker exec douyinweb-neko-3 supervisorctl status google-chrome
|
|
"""
|
|
_i, o, e = c.exec_command(cmd, timeout=600)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
err = e.read().decode("utf-8", "replace")
|
|
if err.strip():
|
|
print("ERR", err[:2000])
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|