douyinWEB/scripts/_deploy_neko_restart_fix.py
eric d409e416da Ship physical dual-edge stack, Studio CDP live metrics, and ops tooling.
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>
2026-09-04 22:42:40 -05:00

61 lines
1.9 KiB
Python

# -*- coding: utf-8 -*-
"""Deploy Neko restart tab fix (browser-launch + live-ops extension)."""
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/manifest.json",
]
def main() -> None:
launch = ROOT / FILES[0]
launch.write_bytes(launch.read_bytes().replace(b"\r\n", b"\n").replace(b"\r", b"\n"))
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(HOST, 22, "root", PASS, timeout=60, allow_agent=False, look_for_keys=False)
sftp = client.open_sftp()
for rel in FILES:
local = ROOT / rel
remote = f"/opt/douyinWEB/{rel.replace(chr(92), '/')}"
sftp.put(str(local), remote)
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
for id in 1 2 3 4 5; do
name=douyinweb-neko-$id
if docker ps --format '{{.Names}}' | grep -qx "$name"; then
echo "=== restart chrome in $name ==="
docker exec "$name" supervisorctl restart google-chrome 2>/dev/null || docker exec "$name" supervisorctl restart chromium 2>/dev/null || true
docker exec "$name" sh -c 'grep -n profile_has_session /etc/neko/browser-launch.sh | head -1; grep version /etc/neko/live-ops-extension/manifest.json | head -1'
fi
done
"""
_i, o, e = client.exec_command(cmd, timeout=180)
print(o.read().decode("utf-8", "replace"))
err = e.read().decode("utf-8", "replace")
if err.strip():
print("STDERR", err[:1500])
client.close()
print("done")
if __name__ == "__main__":
main()