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

38 lines
1.4 KiB
Python

# -*- coding: utf-8 -*-
import sys
import paramiko
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)
remote = r'''
import json, sqlite3, time
db = sqlite3.connect("/opt/douyinWEB/backend/data/monitor.db")
now = time.time()
cur = db.execute(
"UPDATE tiktok_jobs SET status=?, error=?, finished_at=?, updated_at=? WHERE status IN ('scheduled','uploading')",
("failed", "紧急停止重复上传", now, now),
)
print("frozen", cur.rowcount)
db.execute("INSERT OR REPLACE INTO kv_settings(key, value) VALUES (?, ?)", ("tiktok_auto_retry_failed", json.dumps(False)))
print("jobs")
for r in db.execute("SELECT status, count(*) n FROM tiktok_jobs GROUP BY status"):
print(dict(r) if False else r)
print("retry", db.execute("SELECT value FROM kv_settings WHERE key='tiktok_auto_retry_failed'").fetchone())
db.commit()
db.close()
'''
sftp = c.open_sftp()
with sftp.file("/tmp/_freeze_tt.py", "w") as f:
f.write(remote)
sftp.close()
_s, out, err = c.exec_command("/opt/douyinWEB/backend/.venv/bin/python /tmp/_freeze_tt.py", timeout=30)
print(out.read().decode("utf-8", "replace"))
e = err.read().decode("utf-8", "replace")
if e:
print("ERR:", e[:500])
c.exec_command("rm -f /tmp/_freeze_tt.py")
c.close()