Commit ebcef114321d14623dfc24e9fb2a57eb01d70a7b
1 parent
c07ee772
raylight/h3-console: 补 systemd 开机自启
服务器意外重启后 raylight/h3-console 全灭才发现之前没有任何开机自启配置, 补上三个 unit(raylight.service 只管开机拉起一次,两个 h3-console 实例走 Restart=on-failure),详见 CHANGELOG。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Showing
6 changed files
with
93 additions
and
0 deletions
CHANGELOG.md
| 1 | 1 | # 变更记录 |
| 2 | 2 | |
| 3 | +## 2026-08-25(晚)— 服务器意外重启后 raylight/h3-console 全灭,补上 systemd 开机自启 | |
| 4 | + | |
| 5 | +**背景**:用户反馈 `http://192.168.110.67:8080/newtask.html` 打不开。排查发现机器在当天 | |
| 6 | +23:04 自己重启过(`uptime`/`last reboot` 确认,非人为操作),重启后 GPU 显存全空、 | |
| 7 | +ComfyUI(8188)/raylight-server(8100)/h3-console(8080/8081) 全部没起来——**这台机器此前 | |
| 8 | +没有任何开机自启配置**(既无 systemd unit 也无 crontab),全靠手动 `start.sh`/`run.sh`。 | |
| 9 | + | |
| 10 | +**修复**:临时先手动 `bash raylight/scripts/start.sh` + 手动起两个 h3-console 实例恢复服务, | |
| 11 | +然后补了三个 systemd unit(本地副本见 `raylight/scripts/raylight.service`、 | |
| 12 | +`h3-console/systemd/h3-console-lan.service`、`h3-console/systemd/h3-console-public.service`, | |
| 13 | +服务器上装在 `/etc/systemd/system/`): | |
| 14 | + | |
| 15 | +- `raylight.service`:`Type=oneshot` + `RemainAfterExit=yes` 包一层 `start.sh`,只负责 | |
| 16 | + **开机拉起一次**,**故意不设 `Restart=`**——崩溃自愈已经交给 `watchdog.sh`,两套自动重启 | |
| 17 | + 机制并存会重现 8月24日 PM2 那次「谁在重启」的排查混乱。 | |
| 18 | +- `h3-console-lan.service`(8080) / `h3-console-public.service`(8081):`Type=simple` 直接 | |
| 19 | + `ExecStart=run.sh`(脚本末尾是 `exec uvicorn`,进程替换后 systemd 能正确跟踪主进程), | |
| 20 | + 日志仍然 `append` 到原来的 `console-8080.log`/`console-subpath.log`,不改用 journald, | |
| 21 | + 保留原有排查习惯;这两个是无状态 FastAPI,加了 `Restart=on-failure` 没有已知冲突。 | |
| 22 | +- 三者都已 `enable`。console 两个实例已经停掉手动进程、切到 systemd 管理并验证 200; | |
| 23 | + `raylight.service` 因为手动起的进程当时健康在跑,为避免几分钟模型重载中断没有强制重启 | |
| 24 | + 「认领」,只对下次开机生效。 | |
| 25 | + | |
| 26 | +**遗留**:没有实测过真的 `reboot` 验证三个 unit 顺序拉起是否顺畅(尤其 raylight 启动要等 | |
| 27 | +ComfyUI+4卡FSDP集群就绪,可能需要 `TimeoutStartSec` 更宽裕),下次计划性重启时留意确认。 | |
| 28 | + | |
| 3 | 29 | ## 2026-08-25(凌晨)— 修复 watchdog.sh 误杀:把"采样跑完/VAE存盘中"当成卡死重启,打断了一批正在跑的任务 |
| 4 | 30 | |
| 5 | 31 | **背景**:批量重跑 16 个 h3-showcase 案例期间,队列跑到一半突然又出现"进程重启导致任务被取消/ | ... | ... |
h3-console/README.md
| ... | ... | @@ -143,6 +143,13 @@ PID=$(ss -lptn "sport = :8080" | grep -o "pid=[0-9]*" | cut -d= -f2 | sort -u) |
| 143 | 143 | [ -n "$PID" ] && kill $PID |
| 144 | 144 | ``` |
| 145 | 145 | |
| 146 | +**开机自启(2026-08-25 补)**:两个实例现在都由 systemd 管理——`/etc/systemd/system/ | |
| 147 | +h3-console-lan.service`(8080)、`h3-console-public.service`(8081),本地副本见 | |
| 148 | +`systemd/` 目录,已 `enable`。`ExecStart` 直接指向 `run.sh`(脚本末尾 `exec uvicorn`, | |
| 149 | +进程替换后 systemd 能正确跟踪),日志仍 `append` 到原来的 `console-8080.log`/ | |
| 150 | +`console-subpath.log`(不改用 journald),加了 `Restart=on-failure`。改配置后用 | |
| 151 | +`systemctl restart h3-console-lan h3-console-public` 生效,不用再手动 kill 端口。 | |
| 152 | + | |
| 146 | 153 | **部署后验过**:`curl http://192.168.110.67:8080/v1/backends` 看到 4/4 ready;提交一个 fl2va |
| 147 | 154 | 首尾帧任务,`console.log` 里能看到 `[supervisor] flip port=... ref2va -> fl2va`,30 秒后(空闲 |
| 148 | 155 | 判定)触发一次、只触发一次,新后端 ready 后任务自动提交并跑完,下载代理拿到合法 mp4。 | ... | ... |
h3-console/systemd/h3-console-lan.service
0 → 100644
| 1 | +[Unit] | |
| 2 | +Description=h3-console (LAN instance, port 8080, elastic supervisor off) | |
| 3 | +After=network.target raylight.service | |
| 4 | + | |
| 5 | +[Service] | |
| 6 | +Type=simple | |
| 7 | +User=admin | |
| 8 | +WorkingDirectory=/data/models/minimax-h3/console | |
| 9 | +Environment=H3_GATEWAY_URL=http://127.0.0.1:8100 | |
| 10 | +Environment=H3_CONSOLE_PUBLIC_BASE=http://192.168.110.67:8080 | |
| 11 | +Environment=PORT=8080 | |
| 12 | +ExecStart=/data/models/minimax-h3/console/run.sh | |
| 13 | +StandardOutput=append:/data/models/minimax-h3/console/console-8080.log | |
| 14 | +StandardError=append:/data/models/minimax-h3/console/console-8080.log | |
| 15 | +Restart=on-failure | |
| 16 | +RestartSec=5 | |
| 17 | + | |
| 18 | +[Install] | |
| 19 | +WantedBy=multi-user.target | ... | ... |
h3-console/systemd/h3-console-public.service
0 → 100644
| 1 | +[Unit] | |
| 2 | +Description=h3-console (public /console subpath instance, port 8081) | |
| 3 | +After=network.target raylight.service | |
| 4 | + | |
| 5 | +[Service] | |
| 6 | +Type=simple | |
| 7 | +User=admin | |
| 8 | +WorkingDirectory=/data/models/minimax-h3/console | |
| 9 | +Environment=H3_GATEWAY_URL=http://127.0.0.1:8100 | |
| 10 | +Environment=H3_CONSOLE_PUBLIC_BASE=http://192.168.110.67:8080 | |
| 11 | +Environment=H3_CONSOLE_BASE_PATH=/console | |
| 12 | +Environment=PORT=8081 | |
| 13 | +ExecStart=/data/models/minimax-h3/console/run.sh | |
| 14 | +StandardOutput=append:/data/models/minimax-h3/console/console-subpath.log | |
| 15 | +StandardError=append:/data/models/minimax-h3/console/console-subpath.log | |
| 16 | +Restart=on-failure | |
| 17 | +RestartSec=5 | |
| 18 | + | |
| 19 | +[Install] | |
| 20 | +WantedBy=multi-user.target | ... | ... |
raylight/README.md
| ... | ... | @@ -30,6 +30,11 @@ bash /data/models/raylight/start.sh |
| 30 | 30 | 脚本会按端口停掉已在跑的 ComfyUI(8188)/raylight-server(8100),重新拉起两者,轮询健康检查。 |
| 31 | 31 | 照抄的是 `minimax-h3/start-all.sh` 的模式(按端口 `ss -lptn` 找PID kill,不用 `pkill -f`)。 |
| 32 | 32 | |
| 33 | +**开机自启(2026-08-25 补)**:`/etc/systemd/system/raylight.service` 包了这个脚本 | |
| 34 | +(`Type=oneshot`+`RemainAfterExit=yes`,已 `enable`),本地副本见 `scripts/raylight.service`。 | |
| 35 | +故意不设 `Restart=`——崩溃自愈交给 `watchdog.sh`,两套自动重启机制并存会重现 8月24日 PM2 | |
| 36 | +那次「谁在重启」的排查混乱,这个 unit 只管开机拉起一次。 | |
| 37 | + | |
| 33 | 38 | ## 怎么停 / 回滚到旧的 minimax-h3 |
| 34 | 39 | |
| 35 | 40 | ```bash | ... | ... |
raylight/scripts/raylight.service
0 → 100644
| 1 | +[Unit] | |
| 2 | +Description=Raylight ComfyUI + FSDP server (MiniMax-H3 backend, 4-GPU cluster) | |
| 3 | +After=network.target | |
| 4 | + | |
| 5 | +[Service] | |
| 6 | +Type=oneshot | |
| 7 | +RemainAfterExit=yes | |
| 8 | +User=admin | |
| 9 | +WorkingDirectory=/data/models/raylight | |
| 10 | +ExecStart=/data/models/raylight/start.sh | |
| 11 | +TimeoutStartSec=300 | |
| 12 | +# 故意不设 Restart=:崩溃后的自愈已经交给 watchdog.sh 处理,两套自动重启机制并存 | |
| 13 | +# 会重现 CHANGELOG 2026-08-24「排查清楚谁在重启」那次混乱。这个 unit 只管开机拉起一次。 | |
| 14 | + | |
| 15 | +[Install] | |
| 16 | +WantedBy=multi-user.target | ... | ... |