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>
45 lines
1.6 KiB
Python
45 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Emergency: pause X auto-post + cancel queued posts (daily limit hit)."""
|
|
import sys
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
REMOTE = r"""
|
|
cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'
|
|
from app import db
|
|
from app.db import _connect, _lock
|
|
from app.timeutil import push_date_from_ts
|
|
import time
|
|
db.init_db()
|
|
db.update_settings_map({"x_clips_auto_post": False})
|
|
day = push_date_from_ts(time.time())
|
|
now = time.time()
|
|
with _lock:
|
|
conn = _connect()
|
|
try:
|
|
cur = conn.execute(
|
|
"UPDATE x_clip_jobs SET status='skipped', error='x_daily_post_limit', finished_at=?, updated_at=? "
|
|
"WHERE push_date=? AND status IN ('scheduled','recorded','pending') AND IFNULL(x2_job_id,'')=''",
|
|
(now, now, day),
|
|
)
|
|
skipped = cur.rowcount
|
|
cur2 = conn.execute(
|
|
"UPDATE x2_jobs SET status='cancelled', error='x_daily_post_limit', progress_message='X 日发帖上限' "
|
|
"WHERE kind='engage.post' AND status IN ('queued','running')"
|
|
)
|
|
cancelled = cur2.rowcount
|
|
conn.commit()
|
|
print("auto_post=False skipped=", skipped, "cancelled=", cancelled)
|
|
print("x_clips_auto_post", db.get_settings_map().get("x_clips_auto_post"))
|
|
finally:
|
|
conn.close()
|
|
PY
|
|
"""
|
|
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)
|
|
_, o, e = c.exec_command(REMOTE, timeout=90)
|
|
print((o.read() + e.read()).decode("utf-8", "replace").strip())
|
|
c.close()
|
|
print("DONE")
|