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>
44 lines
1.7 KiB
Python
44 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Emergency: purge duplicate x2_jobs queued by the repost bug."""
|
|
import sys, paramiko, time
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False)
|
|
def run(cmd):
|
|
_, o, e = c.exec_command(cmd, timeout=60)
|
|
return (o.read()+e.read()).decode("utf-8","replace").strip()
|
|
|
|
# 1) Cancel all queued x2 engage.post jobs
|
|
# 2) Cancel running ones that haven't started yet
|
|
print(run(r"""cd /opt/douyinWEB/backend && .venv/bin/python -c "
|
|
from app import db
|
|
db.init_db()
|
|
from app.db import _connect, _lock
|
|
import time
|
|
with _lock:
|
|
conn = _connect()
|
|
try:
|
|
# Cancel all queued engage.post
|
|
cur = conn.execute(\"\"\"
|
|
UPDATE x2_jobs SET status='cancelled', error='purge_repost_bug'
|
|
WHERE status='queued' AND kind='engage.post'
|
|
\"\"\")
|
|
print('cancelled queued:', cur.rowcount)
|
|
# Cancel running engage.post stuck on startup
|
|
cur2 = conn.execute(\"\"\"
|
|
UPDATE x2_jobs SET status='cancelled', error='purge_repost_bug'
|
|
WHERE status='running' AND kind='engage.post'
|
|
AND progress_message IN ('启动中…', '启动中', '插件执行中')
|
|
\"\"\")
|
|
print('cancelled stuck running:', cur2.rowcount)
|
|
conn.commit()
|
|
# verify
|
|
total = conn.execute('SELECT status, COUNT(*) c FROM x2_jobs GROUP BY status').fetchall()
|
|
print('after:', {r['status']:r['c'] for r in total})
|
|
finally:
|
|
conn.close()
|
|
" """))
|
|
c.close()
|
|
print("DONE")
|