feat: 进程守护 supervise.sh,崩溃自动重启;DEPLOY 补 docker healthcheck
- scripts/supervise.sh:web_server 崩溃自动重启,带 2s 退避和 300s 窗口内重启上限(10次)防死循环 - doc/DEPLOY.md 补充通用守护用法 + python-app 容器 healthcheck 配置
This commit is contained in:
@@ -149,6 +149,31 @@ RestartSec=10
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
**通用脚本(Linux/macOS,无需 systemd)**:
|
||||
|
||||
项目自带 `scripts/supervise.sh`:web_server 崩溃自动重启、带退避和重启上限(防崩溃死循环)。
|
||||
|
||||
```bash
|
||||
# 用 venv 的 python 守护
|
||||
PYTHON=./.venv/bin/python bash scripts/supervise.sh
|
||||
```
|
||||
|
||||
> 进程守护只保证服务重启,不恢复已运行的任务(worker 状态在内存)。崩溃后残留的设备占用需用"强制释放占用"清理(或启动时的提示)。
|
||||
|
||||
**Docker(生产 python-app 容器)**:
|
||||
|
||||
docker-compose 已配置 `restart: unless-stopped`,web_server 进程退出 → 容器退出 → Docker 自动重启。建议再加健康检查,让编排感知服务存活:
|
||||
|
||||
```yaml
|
||||
# docker-compose.yaml 的 python-app 服务下添加
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:18050/api/health', timeout=3)"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
```
|
||||
|
||||
### 3.2 反向代理(可选)
|
||||
|
||||
如需 HTTPS 或 80 端口,用 Nginx 反向代理:
|
||||
|
||||
Reference in New Issue
Block a user