fix: Caddy 用 handle_path 自动 strip /api 前缀
之前的 reverse_proxy /api/* 直接转发保留路径,导致 api 收到 /api/v1/articles 而实际路由是 /v1/articles(API_PREFIX)。改用 handle_path。
This commit is contained in:
36
scripts/_recover.py
Normal file
36
scripts/_recover.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import os, paramiko
|
||||
PW = os.environ["REMOTE_PASS"]
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect("207.57.129.228", port=19717, username="root", password=PW, timeout=15, allow_agent=False, look_for_keys=False)
|
||||
|
||||
def run(cmd, t=60):
|
||||
si, so, se = c.exec_command(cmd, timeout=t)
|
||||
out = so.read().decode("utf-8", "replace")
|
||||
err = se.read().decode("utf-8", "replace")
|
||||
rc = so.channel.recv_exit_status()
|
||||
print(f"$ {cmd}")
|
||||
if out: print(out, end="")
|
||||
if err: print("[err]", err, end="", file=__import__("sys").stderr)
|
||||
print(f" rc={rc}")
|
||||
return out
|
||||
|
||||
# 1) 服务器 pull
|
||||
run("cd /srv/news && sudo -u news git pull --rebase 2>&1 | tail -5")
|
||||
|
||||
# 2) 重建 api + worker 容器(代码变更需要重启)
|
||||
run("cd /srv/news && sg docker -c 'docker compose up -d --build --no-deps api worker' 2>&1 | tail -10")
|
||||
|
||||
# 3) 等启动
|
||||
import time
|
||||
time.sleep(15)
|
||||
|
||||
# 4) 跑 seed
|
||||
run("cd /srv/news && sg docker -c \"docker compose exec -T api python -m app.scripts.seed_sources\" 2>&1 | tail -20")
|
||||
|
||||
# 5) 看 docker ps
|
||||
run("cd /srv/news && sg docker -c 'docker compose ps' 2>&1 | head -15")
|
||||
|
||||
# 6) 健康
|
||||
run("curl -s http://localhost/api/v1/healthz 2>&1")
|
||||
c.close()
|
||||
Reference in New Issue
Block a user