Wire Taro social pages to social_svc (Centrifugo + live RTMP), drop multi-channel chat chrome, and add weapp WXSS sanitize/deploy helpers. Co-authored-by: Cursor <cursoragent@cursor.com>
99 lines
3.2 KiB
Python
99 lines
3.2 KiB
Python
# -*- coding: utf-8 -*-
|
||
"""Push social-join virtual pay routes to production (/opt/nomadmini)."""
|
||
from __future__ import annotations
|
||
|
||
import time
|
||
from pathlib import Path
|
||
|
||
import paramiko
|
||
|
||
REPO = Path(__file__).resolve().parents[3]
|
||
HOST, USER, PASS = "82.157.112.245", "ubuntu", "Xiao4669805"
|
||
|
||
|
||
def to_app_pkg(src: Path) -> bytes:
|
||
data = src.read_text(encoding="utf-8").replace("ebook_svc.", "app.").encode("utf-8")
|
||
assert b"ebook_svc" not in data, f"rewrite failed: {src}"
|
||
return data
|
||
|
||
|
||
def main() -> int:
|
||
pairs = [
|
||
(
|
||
REPO / "apps/api/services/ebook_svc/core/rate_limit.py",
|
||
"/tmp/rate_limit_app.py",
|
||
"/opt/nomadmini/backend/app/core/rate_limit.py",
|
||
),
|
||
(
|
||
REPO / "apps/api/services/ebook_svc/services/social_join_config.py",
|
||
"/tmp/social_join_config_app.py",
|
||
"/opt/nomadmini/backend/app/services/social_join_config.py",
|
||
),
|
||
(
|
||
REPO / "apps/api/services/ebook_svc/routers/pay.py",
|
||
"/tmp/pay_app.py",
|
||
"/opt/nomadmini/backend/app/routers/pay.py",
|
||
),
|
||
]
|
||
c = paramiko.SSHClient()
|
||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||
c.connect(
|
||
HOST,
|
||
username=USER,
|
||
password=PASS,
|
||
timeout=60,
|
||
allow_agent=False,
|
||
look_for_keys=False,
|
||
)
|
||
sftp = c.open_sftp()
|
||
for src, tmp, _final in pairs:
|
||
data = to_app_pkg(src)
|
||
with sftp.file(tmp, "wb") as rf:
|
||
rf.write(data)
|
||
print("up", tmp, len(data), flush=True)
|
||
sftp.close()
|
||
|
||
cmd = r"""
|
||
set -e
|
||
B=/opt/nomadmini/backend/app
|
||
sudo cp /tmp/rate_limit_app.py "$B/core/rate_limit.py"
|
||
sudo cp /tmp/social_join_config_app.py "$B/services/social_join_config.py"
|
||
sudo cp /tmp/pay_app.py "$B/routers/pay.py"
|
||
cd /opt/nomadmini/backend
|
||
.venv/bin/python - <<'PY'
|
||
from app.core.rate_limit import rate_limit
|
||
from app.services.social_join_config import SOCIAL_JOIN_BOOK_ID, read_social_join_config
|
||
from app.routers import pay
|
||
print(
|
||
"import_ok",
|
||
SOCIAL_JOIN_BOOK_ID,
|
||
hasattr(pay, "create_social_join_order"),
|
||
callable(rate_limit),
|
||
read_social_join_config().get("socialJoinEnabled"),
|
||
)
|
||
PY
|
||
sudo systemctl restart nomadmini-api
|
||
sleep 4
|
||
systemctl is-active nomadmini-api
|
||
curl -sk -o /dev/null -w "health %{http_code}\n" https://api.nomadro.cn/health || true
|
||
# 未登录应 401,不应再 404
|
||
curl -sk -o /dev/null -w "sj-status %{http_code}\n" https://api.nomadro.cn/api/pay/social-join-status || true
|
||
curl -sk -o /dev/null -w "sj-ebook %{http_code}\n" https://api.nomadro.cn/api/ebook/pay/social-join-status || true
|
||
rm -f /tmp/rate_limit_app.py /tmp/social_join_config_app.py /tmp/pay_app.py
|
||
"""
|
||
_, stdout, _ = c.exec_command(cmd, timeout=180, get_pty=True)
|
||
while not stdout.channel.exit_status_ready():
|
||
if stdout.channel.recv_ready():
|
||
print(stdout.channel.recv(65536).decode("utf-8", "replace"), end="", flush=True)
|
||
time.sleep(0.05)
|
||
while stdout.channel.recv_ready():
|
||
print(stdout.channel.recv(65536).decode("utf-8", "replace"), end="", flush=True)
|
||
code = stdout.channel.recv_exit_status()
|
||
print(f"[exit {code}]", flush=True)
|
||
c.close()
|
||
return code
|
||
|
||
|
||
if __name__ == "__main__":
|
||
raise SystemExit(main())
|