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>
94 lines
2.7 KiB
Python
94 lines
2.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Deploy neko fixes to ALL instances + relay exclusive-live backend."""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import sys
|
|
import tarfile
|
|
import tempfile
|
|
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"
|
|
|
|
INCLUDE = [
|
|
"backend/neko",
|
|
"backend/app/youtube_neko.py",
|
|
"backend/app/youtube_relay_pipeline.py",
|
|
"backend/app/db.py",
|
|
]
|
|
|
|
|
|
def _add(tar: tarfile.TarFile, rel: str) -> None:
|
|
path = ROOT / rel
|
|
if not path.exists():
|
|
raise SystemExit(f"missing {path}")
|
|
tar.add(path, arcname=rel.replace("\\", "/"))
|
|
print("pack", rel)
|
|
|
|
|
|
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"))
|
|
|
|
fd, tmp = tempfile.mkstemp(suffix=".tgz")
|
|
os.close(fd)
|
|
tgz = Path(tmp)
|
|
try:
|
|
with tarfile.open(tgz, "w:gz") as tar:
|
|
for rel in INCLUDE:
|
|
_add(tar, rel)
|
|
|
|
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()
|
|
sftp.put(str(tgz), "/tmp/douyinweb-neko-all.tgz")
|
|
sftp.close()
|
|
|
|
cmd = r"""
|
|
set -e
|
|
cd /opt/douyinWEB
|
|
tar xzf /tmp/douyinweb-neko-all.tgz
|
|
chmod +x /opt/douyinWEB/backend/neko/browser-launch.sh
|
|
sed -i 's/\r$//' /opt/douyinWEB/backend/neko/browser-launch.sh
|
|
systemctl restart douyinweb-api
|
|
sleep 4
|
|
systemctl is-active douyinweb-api
|
|
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)
|
|
print("groups", len(groups), [(g.get("name"), g.get("neko_instance_id"), g.get("neko_enabled")) for g in groups])
|
|
r = youtube_neko.recreate_all_instances(start_enabled=True)
|
|
print("recreate", r)
|
|
PY
|
|
for id in 1 2 3 4 5 6 7 8; do
|
|
name=douyinweb-neko-$id
|
|
if docker inspect $name >/dev/null 2>&1; then
|
|
echo "--- $name ---"
|
|
docker exec $name grep -c focus_live_studio_tab_once /etc/neko/browser-launch.sh 2>/dev/null || echo no_launch
|
|
docker exec $name grep version /etc/neko/live-ops-extension/manifest.json 2>/dev/null | head -1
|
|
docker ps --filter name=$name --format '{{.Names}} {{.Status}}'
|
|
fi
|
|
done
|
|
"""
|
|
_i, o, e = c.exec_command(cmd, timeout=900)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
err = e.read().decode("utf-8", "replace")
|
|
if err.strip():
|
|
print("STDERR", err[:2500])
|
|
c.close()
|
|
finally:
|
|
tgz.unlink(missing_ok=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|