fix: healthz 路径改成 /api/v1/healthz(归到 API 前缀下)

This commit is contained in:
Mavis
2026-06-07 23:15:33 +08:00
parent eaa4aa6604
commit 2e75985a3c
3 changed files with 34 additions and 10 deletions

28
scripts/_restart_caddy.py Normal file
View File

@@ -0,0 +1,28 @@
import os, paramiko, time
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
run("cd /srv/news && sudo -u news git pull --rebase 2>&1 | tail -3")
run("cd /srv/news && sg docker -c 'docker compose up -d --force-recreate caddy' 2>&1 | tail -10")
time.sleep(5)
# 测试路径
print("\n=== healthz 测试 ===")
run("curl -s -o /dev/null -w 'healthz: %{http_code}\\n' http://localhost/healthz")
run("curl -s -o /dev/null -w 'api/healthz: %{http_code}\\n' http://localhost/api/healthz")
run("curl -s -o /dev/null -w 'api/v1/articles: %{http_code}\\n' http://localhost/api/v1/articles")
run("curl -s http://localhost/api/healthz 2>&1")
c.close()