73 lines
2.0 KiB
Python
73 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Recover dylive neko-12 without recreate; check why it stopped."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
for i in range(8):
|
|
try:
|
|
c.connect(
|
|
"107.173.30.245",
|
|
22,
|
|
"root",
|
|
"Xiao4669805",
|
|
timeout=50,
|
|
allow_agent=False,
|
|
look_for_keys=False,
|
|
banner_timeout=180,
|
|
)
|
|
break
|
|
except Exception as e:
|
|
print("retry", i, e)
|
|
time.sleep(2)
|
|
else:
|
|
raise SystemExit("ssh fail")
|
|
|
|
_i, o, e = c.exec_command(
|
|
r"""
|
|
set +e
|
|
echo '=== before ==='
|
|
docker ps -a --filter name=douyinweb-neko-12 --format '{{.Names}} {{.Status}}'
|
|
docker inspect douyinweb-neko-12 --format 'OOM={{.State.OOMKilled}} Exit={{.State.ExitCode}} Error={{.State.Error}} Finished={{.State.FinishedAt}} Status={{.State.Status}}'
|
|
dmesg -T 2>/dev/null | tail -30 | grep -iE 'oom|kill|neko|chrome' || true
|
|
free -m | head -2
|
|
|
|
echo '=== start (no recreate) ==='
|
|
docker start douyinweb-neko-12
|
|
sleep 15
|
|
docker ps --filter name=douyinweb-neko-12 --format '{{.Names}} {{.Status}}'
|
|
docker exec douyinweb-neko-12 sh -c '
|
|
supervisorctl status
|
|
grep -n js-flags /etc/neko/browser-launch.sh | head -1
|
|
rm -f /home/neko/.config/google-chrome/Singleton* 2>/dev/null
|
|
supervisorctl start google-chrome 2>/dev/null || supervisorctl restart google-chrome
|
|
sleep 10
|
|
supervisorctl status google-chrome
|
|
curl -sS -m 3 http://127.0.0.1:9222/json/version | head -c 160; echo
|
|
python3 - <<"PY"
|
|
import json,urllib.request
|
|
try:
|
|
tabs=json.load(urllib.request.urlopen("http://127.0.0.1:9222/json",timeout=5))
|
|
print("tabs",len(tabs))
|
|
for t in tabs:
|
|
if "studio" in (t.get("url") or ""):
|
|
print("studio", (t.get("url") or "")[:100])
|
|
except Exception as e:
|
|
print("err",e)
|
|
PY
|
|
'
|
|
free -m | head -2
|
|
""",
|
|
timeout=180,
|
|
)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|
|
print("DONE")
|