# 🔴 api_server.py 已停止运行 — 公网看板 502

**发现时间**: 2026-09-01 11:34 (Asia/Shanghai)
**发现方**: russell 侧 watchdog（`ai.openclaw.adassistant-proxy` 健康检查）
**影响**: `https://advantage.timespodcast.cc/` 全站 502，外部无法访问投放看板

## 现象

`127.0.0.1:18083` 连接被拒绝（不是超时、不是 404，是没有进程在监听）：

```
curl http://127.0.0.1:18083/cotAwwuZihS1L4tQ
→ curl: (7) Failed to connect to 127.0.0.1 port 18083: Connection refused
```

russell 侧代理返回的错误体也印证了同一点：

```
upstream unreachable: <urlopen error [Errno 61] Connection refused>
```

`ps aux` 全表（跨用户可见）里已无 `api_server.py` 进程。

## 责任划分：不是 russell 侧的问题

链路 `公网 → Cloudflare → cloudflared → :18086 代理 → :18083 api_server.py`
中，前三跳全部正常：

| 组件 | 归属 | 状态 |
|---|---|---|
| cloudflared | russell | ✅ running，last exit code = 0 |
| `adassistant_proxy.py` :18086 | russell | ✅ running (pid 21128)，已 kickstart 11 次 |
| `api_server.py` :18083 | **suyue** | ❌ **不在运行** |

代理本身是健康的 —— 它正确地把上游故障如实报成 502。反复 kickstart 代理无意义，已停止重试。

## 需要 suyue 做的事

1. **先拉起来恢复服务**：`cd <项目目录> && python -u api_server.py`
2. **查为什么死的**：本次不是机器重启导致（机器已连续 uptime 81 天，未重启），所以是进程自身退出 —— 崩溃、OOM、还是终端被关掉？建议翻一下 stdout/stderr 日志
3. **补 launchd 托管**（8/27 交接文档里已提过，本次正好验证了风险）：`api_server.py` 目前 PPID=1、手工启动、无 plist，死了没有任何东西会把它拉起来。加一个带 `KeepAlive=true` 的 LaunchAgent 就能自愈，不必依赖 russell 侧 watchdog 报警 + 人工转达。

⚠️ 本机 launchd 有个坑（russell 侧实测）：往**已存在的 gui domain** 里 bootstrap 新 job，`RunAtLoad` 与 `KeepAlive` 都不触发，只有 `launchctl kickstart` 能拉起。装完 plist 请务必 kickstart 一次并确认 `runs` 有增长。

## 恢复后如何自检

```bash
# 1. 上游自身（suyue 侧）
curl -sS -m 10 -o /dev/null -w '%{http_code}\n' http://127.0.0.1:18083/cotAwwuZihS1L4tQ   # 期望 200

# 2. russell 侧代理（无需 suyue 操作，上游一起就会自动通）
curl -sS -m 15 -o /dev/null -w '%{http_code}\n' http://127.0.0.1:18086/                  # 期望 200

# 3. 公网 —— 必须带 --compressed，否则 28-50s 的假慢会让你以为隧道有问题
curl -sS --compressed -m 40 -o /dev/null -w '%{http_code}\n' https://advantage.timespodcast.cc/  # 期望 200
```

上游一恢复，russell 侧无需任何动作，公网立即自动恢复（反代是实时透传的）。
