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>
32 lines
1.5 KiB
Python
32 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Deploy X daily-limit fix (backend only; extension reload local)."""
|
|
import sys, time, paramiko
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
REPO = "/opt/douyinWEB"
|
|
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, timeout=180):
|
|
_, o, e = c.exec_command(cmd, timeout=timeout)
|
|
return (o.read() + e.read()).decode("utf-8", "replace").strip()
|
|
dirty = run(f"cd {REPO} && git diff --name-only -- backend/app/x_clips_pipeline.py backend/app/x_clips_db.py backend/app/x2_db.py")
|
|
if dirty.strip():
|
|
print("[stash]", run(f"cd {REPO} && git stash push -m auto-before-x-limit -- backend/app/x_clips_pipeline.py backend/app/x_clips_db.py backend/app/x2_db.py"))
|
|
print("[pull]", run(f"cd {REPO} && git pull --ff-only origin test1 && git log --oneline -1"))
|
|
run("systemctl restart douyinweb-api")
|
|
for _ in range(25):
|
|
if run("systemctl is-active douyinweb-api", timeout=15) == "active":
|
|
print("[api] active"); break
|
|
time.sleep(2)
|
|
print(run(r"""cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'
|
|
from app import db
|
|
from app.x_clips_pipeline import is_x_daily_post_limit
|
|
db.init_db()
|
|
assert is_x_daily_post_limit("X_DAILY_POST_LIMIT: You've hit the daily post limit")
|
|
cfg = db.get_settings_map()
|
|
print("auto_post", cfg.get("x_clips_auto_post"))
|
|
print("detect_ok")
|
|
PY"""))
|
|
c.close()
|
|
print("DONE")
|