66 lines
2.1 KiB
Python
66 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Sync cleaned browser-launch.sh to dy; refresh chrome only if running."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
raw = (
|
|
Path(__file__).resolve().parents[1] / "backend" / "neko" / "browser-launch.sh"
|
|
).read_bytes().replace(b"\r\n", b"\n").replace(b"\r", b"\n")
|
|
assert b"--jitless" in raw and b"--no-wasm-simd" not in raw
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(
|
|
"108.174.50.68",
|
|
22,
|
|
"root",
|
|
"Xiao4669805",
|
|
timeout=60,
|
|
allow_agent=False,
|
|
look_for_keys=False,
|
|
banner_timeout=300,
|
|
)
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/opt/douyinWEB/backend/neko/browser-launch.sh", "wb") as f:
|
|
f.write(raw)
|
|
sftp.chmod("/opt/douyinWEB/backend/neko/browser-launch.sh", 0o755)
|
|
sftp.close()
|
|
|
|
_i, o, e = c.exec_command(
|
|
r"""
|
|
set +e
|
|
# overwrite inodes of any running neko mounts
|
|
for name in $(docker ps --format '{{.Names}}' | grep '^douyinweb-neko-'); do
|
|
INO=$(docker exec "$name" sh -c 'ls -li /etc/neko/browser-launch.sh' 2>/dev/null | awk '{print $1}')
|
|
[ -z "$INO" ] && continue
|
|
MATCH=$(find /opt /root -xdev -inum "$INO" 2>/dev/null | head -1)
|
|
if [ -n "$MATCH" ]; then
|
|
cat /opt/douyinWEB/backend/neko/browser-launch.sh > "$MATCH"
|
|
echo FIXED_$name inode=$INO
|
|
else
|
|
echo PATHONLY_$name
|
|
fi
|
|
docker exec "$name" sh -c 'grep -n js-flags /etc/neko/browser-launch.sh | head -1'
|
|
# restart chrome only if currently RUNNING
|
|
if docker exec "$name" supervisorctl status google-chrome 2>/dev/null | grep -q RUNNING; then
|
|
docker exec "$name" sh -c 'rm -f /home/neko/.config/google-chrome/Singleton*; supervisorctl restart google-chrome'
|
|
sleep 8
|
|
docker exec "$name" supervisorctl status google-chrome
|
|
docker exec "$name" curl -sS -m 3 http://127.0.0.1:9222/json/version | head -c 120; echo
|
|
else
|
|
echo SKIP_chrome_$name
|
|
fi
|
|
done
|
|
docker ps --filter name=douyinweb-neko --format '{{.Names}} {{.Status}}'
|
|
""",
|
|
timeout=240,
|
|
)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|
|
print("DONE")
|