douyinWEB/scripts/_fix_frp_master_lock.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

60 lines
2.3 KiB
Python

# -*- coding: utf-8 -*-
import sys, time, paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
# 1) checkpoint + restart master frp-panel to clear sqlite lock
# 2) restart vps frpp so it re-registers cleanly after master is up
m=paramiko.SSHClient(); m.set_missing_host_key_policy(paramiko.AutoAddPolicy())
m.connect('107.172.77.34',22,'root','Xiao4669805',timeout=45,allow_agent=False,look_for_keys=False)
print('=== checkpoint WAL on master ===')
_,o,e=m.exec_command(r'''
set -e
# stop writes briefly by restarting container after checkpoint attempt via sqlite3 if available
python3 - <<'PY'
import sqlite3, time
# copy-on open may fail if locked; try busy timeout
for i in range(5):
try:
c=sqlite3.connect('/opt/frp-panel/data.db', timeout=30)
c.execute('PRAGMA busy_timeout=30000')
print('wal_before', c.execute('PRAGMA wal_checkpoint(TRUNCATE)').fetchone())
print('integrity', c.execute('PRAGMA integrity_check').fetchone())
c.close(); break
except Exception as ex:
print('try', i, ex); time.sleep(2)
PY
echo restarting docker frp-panel...
docker restart frp-panel
sleep 5
docker ps --filter name=frp-panel --format '{{.Names}} {{.Status}}'
ss -lntp | grep -E ':(9000|9001|7000)\b'
curl -sS -o /dev/null -w 'login_page:%{http_code}\n' --max-time 10 http://127.0.0.1:9000/login
''', timeout=120)
print(o.read().decode('utf-8','replace'))
print(e.read().decode('utf-8','replace')[-1000:])
m.close()
print('=== restart VPS frpp ===')
v=paramiko.SSHClient(); v.set_missing_host_key_policy(paramiko.AutoAddPolicy())
v.connect('107.173.30.245',22,'root','Xiao4669805',timeout=45,allow_agent=False,look_for_keys=False)
_,o,e=v.exec_command(r'''
systemctl restart frpp
sleep 4
systemctl is-active frpp
ss -lntp | grep frp-panel
journalctl -u frpp --no-pager -n 25 | tail -25
''', timeout=60)
print(o.read().decode('utf-8','replace'))
print(e.read().decode('utf-8','replace')[-500:])
v.close()
time.sleep(8)
print('=== post-check listeners on VPS ===')
v=paramiko.SSHClient(); v.set_missing_host_key_policy(paramiko.AutoAddPolicy())
v.connect('107.173.30.245',22,'root','Xiao4669805',timeout=45,allow_agent=False,look_for_keys=False)
_,o,_=v.exec_command('ss -lntp | grep frp-panel; journalctl -u frpp --since "2 min ago" --no-pager | grep -iE "new proxy|login info|error" | tail -30', timeout=40)
print(o.read().decode('utf-8','replace'))
v.close()