80 lines
2.4 KiB
Python
80 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Drop invalid --no-wasm-simd; refresh dylive neko-12 launch + chrome."""
|
|
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
|
|
assert b"--no-wasm-simd" not in raw
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(
|
|
"107.173.30.245",
|
|
22,
|
|
"root",
|
|
"Xiao4669805",
|
|
timeout=60,
|
|
allow_agent=False,
|
|
look_for_keys=False,
|
|
banner_timeout=300,
|
|
)
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/tmp/browser-launch-lf.sh", "wb") as f:
|
|
f.write(raw)
|
|
sftp.chmod("/tmp/browser-launch-lf.sh", 0o755)
|
|
# overwrite canonical host path (remounted after last restart)
|
|
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
|
|
# also overwrite whatever inode container currently has
|
|
INO=$(docker exec douyinweb-neko-12 sh -c 'ls -li /etc/neko/browser-launch.sh' | awk '{print $1}')
|
|
MATCH=$(find /opt /root -xdev -inum "$INO" 2>/dev/null | head -1)
|
|
echo CTR_INO=$INO MATCH=$MATCH
|
|
if [ -n "$MATCH" ]; then
|
|
cat /tmp/browser-launch-lf.sh > "$MATCH"
|
|
chmod 755 "$MATCH"
|
|
else
|
|
# path remount: restart keeps profile volumes
|
|
docker restart douyinweb-neko-12
|
|
sleep 12
|
|
fi
|
|
|
|
docker exec douyinweb-neko-12 sh -c '
|
|
grep -n "js-flags\|jitless\|no-wasm" /etc/neko/browser-launch.sh | head -5
|
|
sh -n /etc/neko/browser-launch.sh && echo syntax_ok
|
|
rm -f /home/neko/.config/google-chrome/Singleton* 2>/dev/null
|
|
supervisorctl restart google-chrome
|
|
sleep 12
|
|
supervisorctl status google-chrome
|
|
tail -20 /var/log/neko/google-chrome.log 2>/dev/null | grep -E "unrecognized|FATAL|ERROR:.*Aw|DevTools|Listening" || true
|
|
curl -sS -m 3 http://127.0.0.1:9222/json/version
|
|
# open studio briefly
|
|
python3 - <<PY
|
|
import json,urllib.request
|
|
tabs=json.load(urllib.request.urlopen("http://127.0.0.1:9222/json",timeout=5))
|
|
print("tabs",len(tabs))
|
|
for t in tabs[:3]:
|
|
print(t.get("type"), (t.get("url") or "")[:80], (t.get("title") or "")[:40])
|
|
PY
|
|
'
|
|
docker ps --filter name=douyinweb-neko-12 --format '{{.Names}} {{.Status}}'
|
|
""",
|
|
timeout=180,
|
|
)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|
|
print("DONE")
|