HEL-913 close-out: executable package version/dir entry, consistent pending-approval enablement, complete auditable mem0 install (isolated venv), identity-checked ctl scripts + voice-window wiring (42/42 offline stub checks), fact-table accuracy fixes
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
+249
-83
@@ -1,63 +1,86 @@
|
||||
# HEL-913 · 统一体验运行包(固定版本,未部署、cap=0)
|
||||
|
||||
> 本目录是把已通过 HEL-912 审核的统一候选装成的**可交接运行包**:精确源码版本、
|
||||
> 产物与哈希、脱敏配置模板、唯一启动方式、独立空资料空间、停止/备份/保留资料
|
||||
> 回退说明,以及一次零真实调用的运行准备验证记录。**本卡未部署任何现网服务、
|
||||
> 未监听 836x/8082/9880/8090、未改任何现有实例;实际启用与新用量由总管统一
|
||||
> 向白栖知说明后再执行。**
|
||||
> 本目录是把已通过 HEL-912 审核的统一候选装成的**可交接运行包**:精确源码
|
||||
> 版本、产物与哈希、脱敏配置模板、唯一启动方式、独立空资料空间、停止/
|
||||
> 备份/保留资料回退说明、一次零真实调用的运行准备验证记录、真实记忆的
|
||||
> 完整可审安装清单,以及语音窗口的唯一布防接线。**本卡未部署任何现网
|
||||
> 服务、未监听 836x/8082/9880/8090、未改任何现有实例;实际启用与新用量
|
||||
> 由总管统一向白栖知说明并获批准后再执行。**
|
||||
|
||||
## 0. 精确版本与授权来源
|
||||
## 0. 精确版本:产品基线 vs 运行包提交(不要混同)
|
||||
|
||||
- **候选分支** `agent/2/8e99cc2cc592`,head **`4a38106eef21c43ba24ab7d07992b1bfe539137d`**
|
||||
(HEL-911:AgentHandoff/shutdown 接缝修复 + 3.66s endpointing 等待归因修复)。
|
||||
父线:`407fc81`(HEL-910 窗口记录)← `958c696`(HEL-908 R1/R2 返工)。
|
||||
- 审核:HEL-912 结论「通过,无必须修复项」。主卡 HEL-797;本卡 HEL-913。
|
||||
- 需求基准 v1.12(`docs/requirements/`),需求检查见 handoff-HEL-913.json。
|
||||
- **已审产品基线**:`agent/2/8e99cc2cc592` @ `4a38106eef21c43ba24ab7d07992b1bfe539137d`
|
||||
(HEL-911 接缝修复;HEL-912 审核「通过,无必须修复项」)。父线:
|
||||
`407fc81`(HEL-910 窗口记录)← `958c696`(HEL-908 R1/R2 返工)。
|
||||
**产品代码(src/web/config/tools/tests)以这个提交为准。**
|
||||
- **运行包提交**:同一分支上、`4a38106` 之后的追加提交——只新增/修改
|
||||
`deploy/hel913-unified/` 与 `docs/` 下文件,**不改任何产品代码**。交付
|
||||
评论给出运行包精确 head;本文件自身就在该提交里,所以不能在文件内
|
||||
写死自己的哈希。部署**照抄入口是运行包提交**(本目录随它一起走),
|
||||
只 checkout `4a38106` 会没有本目录——这是收口修正点,别再踩。
|
||||
- **部署前自校验**(两条都必须通过):
|
||||
```bash
|
||||
git merge-base --is-ancestor 4a38106eef21c43ba24ab7d07992b1bfe539137d HEAD && echo ok
|
||||
git diff --stat 4a38106eef21c43ba24ab7d07992b1bfe539137d HEAD -- src web config tools tests # 必须为空
|
||||
```
|
||||
- 需求基准 v1.12(`docs/requirements/`),需求检查见 `handoff-HEL-913.json`。
|
||||
|
||||
## 1. 交付物清单(本目录)
|
||||
|
||||
| 文件 | 作用 |
|
||||
| --- | --- |
|
||||
| `README.md` | 本运行说明(唯一照抄入口) |
|
||||
| `manifest.json` | 机器可读清单:head、锁文件、dist 哈希、环境引用 |
|
||||
| `README.md` | 本运行说明(唯一照抄入口;不跳旧 HEL-895 通用步骤) |
|
||||
| `manifest.json` | 机器可读清单:产品基线、dist 哈希、环境引用、边界 |
|
||||
| `dist-manifest.json` | web dist 8 文件 SHA256(复用 HEL-910 实测构建) |
|
||||
| `models.template.yaml` | 脱敏模型/预算配置(**一切预算=0**;占位符标注待批写入位置) |
|
||||
| `voice.template.yaml` | 脱敏语音配置(LiveKit/TTS/面板指向占位,真实值服务器本地) |
|
||||
| `worker.env.template` | 语音 worker 环境模板(agent venv 运行) |
|
||||
| `api_ctl.sh` | 统一实例 API 启停(单进程 HTTP+HTTPS 双入口) |
|
||||
| `worker_ctl.sh` | 语音 worker 启停(只按 PID 句柄停止) |
|
||||
| `verify_offline.py` | 零真实调用运行准备验证(34 项检查;TestClient 进程内,不监听端口) |
|
||||
| `voice.template.yaml` | 脱敏语音配置(livekit_url 必须是 wss 桥地址,见 §5) |
|
||||
| `worker.env.template` | 语音 worker 环境模板(含 ASR 窗口闸三项,默认未布防=拒绝一切 ASR) |
|
||||
| `voice-window-arm.template.env` | 语音窗口一次性布防参数模板(默认全 0/未布防) |
|
||||
| `api_ctl.sh` / `worker_ctl.sh` | 统一实例 API(单进程 HTTP+HTTPS)与语音 worker 启停(身份核验版) |
|
||||
| `bridge_ctl.template.sh` | wss TLS 桥启停(获批语音窗口用;浏览器侧语音的前提) |
|
||||
| `tts_ctl.template.sh` | 共享 TTS 9880 窗口内临时恢复/停回(只停自己起的 PID) |
|
||||
| `force_end.template.sh` | 窗口到期强制收尾(`now` 立即 / `watch <epoch>` 到点;封窗停服) |
|
||||
| `verify_offline.py` | 零真实调用运行准备验证(34 项;TestClient 进程内,不监听端口) |
|
||||
| `test_ctl_scripts.sh` | 启停脚本离线替身检查(42 项;stub,零真实服务) |
|
||||
| `mem0-cp311-wheels.txt` | 真实 Mem0 记忆栈 cp311 缺项轮清单(40 项,待批一次性下载) |
|
||||
|
||||
运行记录:`docs/rework/hel913/verify-offline-run.txt`(.12 产品 3.11 venv 实跑 34/34)。
|
||||
运行记录:`docs/rework/hel913/verify-offline-run.txt`(.12 产品 3.11 venv
|
||||
实跑 34/34)、`docs/rework/hel913/ctl-checks-run.txt`(收口轮启停检查 42/42)。
|
||||
|
||||
## 2. 版本固定与产物复用
|
||||
|
||||
- **源码**:head `4a38106`(含 `requirements.lock` 19 项固定版本,Python 3.11 实测)。
|
||||
- **源码**:产品基线 `4a38106`(含 `requirements.lock` 19 项固定版本,
|
||||
Python 3.11 实测)+ 运行包提交(仅本目录与 docs)。
|
||||
- **web dist 复用**:`git diff 958c696 4a38106 -- web/` 为空(网页源码零变动),
|
||||
直接复用 HEL-910 已实测部署的 dist(.12 `/opt/cybergril-hel910/current/web/dist`,
|
||||
REVISION 标记 `958c6962…`),只读拷贝,不安装 node、不重建。8 文件哈希见
|
||||
`dist-manifest.json`(2026-10-29 于 .12 逐文件实测),部署时核对一致即可。
|
||||
- **解释器(既有环境引用,不新建)**:
|
||||
REVISION 标记 `958c6962…`),只读拷贝,不安装 node、不重建、不跳任何会
|
||||
`npm install` 或创建旧端口实例的旧发布步骤(如 `deploy/hel895-release-candidate.md`
|
||||
的通用总装流程——那不是本包的入口)。8 文件哈希见 `dist-manifest.json`
|
||||
(2026-10-29 于 .12 逐文件实测),部署时核对一致即可。
|
||||
- **解释器(既有环境引用,不新建、不增改)**:
|
||||
- 产品 API:`.12 /opt/cybergril-hel879/current/.venv311`(Python 3.11.16,
|
||||
requirements.lock 全量,fastapi 0.159.1 / uvicorn 0.54.0 / httpx 0.28.1 / pydantic 2.14.1)。
|
||||
- 语音 worker:`.12 /opt/voice-agent/agent/venv`(livekit-agents 1.8.8,含 silero VAD)。
|
||||
- 证书:`.12 /opt/cybergril-voice-certs/cybergril-voice.{pem,key}`(既有自签,
|
||||
覆盖 192.168.200.12;语音页 secure context 依赖 HTTPS 入口)。
|
||||
- 本机 LiveKit `ws://127.0.0.1:7880`(常驻);TTS 9880 / 面板 8090 / 语音桥
|
||||
按获批窗口另行启动,未获批保持停机。
|
||||
requirements.lock 全量,fastapi 0.159.1 / uvicorn 0.54.0 / httpx 0.28.1 /
|
||||
pydantic 2.14.1)。**只借用运行,绝不向它安装任何东西**(记忆栈装进
|
||||
本实例自己的隔离 venv,见 §7)。
|
||||
- 语音 worker:`.12 /opt/voice-agent/agent/venv`(livekit-agents 1.8.8,
|
||||
含 silero VAD)。
|
||||
- 证书:`.12 /opt/cybergril-voice-certs/cybergril-voice.{pem,key}`(既有
|
||||
自签,覆盖 192.168.200.12;8361 与 wss 桥 8363 共用)。
|
||||
- 本机 LiveKit `ws://127.0.0.1:7880`(常驻);TTS 9880 / 面板 8090 /
|
||||
wss 桥 8363 只在获批窗口内启动(§5),未获批保持停机。
|
||||
|
||||
## 3. 目标实例布局(唯一布局;用户实例 data 必须为空)
|
||||
|
||||
```
|
||||
/opt/cybergril-hel913/ # 实例根(名字可换;以下结构固定)
|
||||
current/ # git clone 后 checkout 4a38106(或 git archive 解包)
|
||||
current/ # git checkout <运行包提交>(见 §0,不是 4a38106)
|
||||
web/dist/ # 按 dist-manifest.json 核哈希后放入(只读复用件)
|
||||
etc/
|
||||
models.yaml # 由 models.template.yaml 复制,填入获批网关与预算
|
||||
voice.yaml # 由 voice.template.yaml 复制,填入服务器本地值
|
||||
semantic.yaml # (仅批准真实记忆时)由 config/semantic.example.yaml 复制,见 §7
|
||||
data/ # 独立空资料空间:新库从零初始化
|
||||
worker/.env # 由 worker.env.template 复制
|
||||
worker/.env # 由 worker.env.template 复制并填好(占位全清)
|
||||
logs/
|
||||
```
|
||||
|
||||
@@ -65,59 +88,123 @@
|
||||
聊天记录、LiveKit/TTS 凭据、自签证书私钥、agent venv 内实物。用户实例在用户
|
||||
亲自创建前 `companion` 表必须为空(离线验证第 3 项复现该守门)。
|
||||
|
||||
## 4. 启动与停止(唯一方式)
|
||||
## 4. 首次准备与启停(唯一照抄入口)
|
||||
|
||||
### 4.1 首次准备(获批部署窗口内执行一次;不真启动服务)
|
||||
|
||||
```bash
|
||||
# 4.1 API:单进程双入口(HTTP 8360 + HTTPS 8361 共用同一 app 状态;lifespan 只进一次)
|
||||
# 0) 取运行包提交(精确 head 见交付评论;下述校验两条都要过,见 §0)
|
||||
git clone -b agent/2/8e99cc2cc592 ssh://git@192.168.200.36:222/leefer/CyberGril.git \
|
||||
/opt/cybergril-hel913/current
|
||||
cd /opt/cybergril-hel913/current
|
||||
git merge-base --is-ancestor 4a38106eef21c43ba24ab7d07992b1bfe539137d HEAD
|
||||
git diff --stat 4a38106eef21c43ba24ab7d07992b1bfe539137d HEAD -- src web config tools tests # 空
|
||||
|
||||
# 1) 目录骨架(固定布局)
|
||||
mkdir -p /opt/cybergril-hel913/{etc,data,logs,worker}
|
||||
|
||||
# 2) 配置落位(占位符必须全部替换;预算值未经批准一律保持 0)
|
||||
cp deploy/hel913-unified/models.template.yaml /opt/cybergril-hel913/etc/models.yaml
|
||||
cp deploy/hel913-unified/voice.template.yaml /opt/cybergril-hel913/etc/voice.yaml
|
||||
cp deploy/hel913-unified/worker.env.template /opt/cybergril-hel913/worker/.env
|
||||
vi /opt/cybergril-hel913/etc/models.yaml /opt/cybergril-hel913/etc/voice.yaml /opt/cybergril-hel913/worker/.env
|
||||
|
||||
# 3) web dist 只读复用(核哈希后拷入;不装 node、不重建)
|
||||
rsync -a /opt/cybergril-hel910/current/web/dist/ /opt/cybergril-hel913/current/web/dist/
|
||||
python3 - <<'EOF'
|
||||
import hashlib, json, pathlib
|
||||
m = json.loads(pathlib.Path("deploy/hel913-unified/dist-manifest.json").read_text())
|
||||
bad = [k for k, want in m.items()
|
||||
if hashlib.sha256((pathlib.Path("web/dist")/k).read_bytes()).hexdigest() != want]
|
||||
raise SystemExit(f"dist hash mismatch: {bad}" if bad else 0)
|
||||
EOF
|
||||
|
||||
# 4) 未创建档案守门复验(进程内 TestClient,零监听零出站;34 项全过才继续)
|
||||
PYTHONPATH=src /opt/cybergril-hel879/current/.venv311/bin/python \
|
||||
deploy/hel913-unified/verify_offline.py --web web/dist
|
||||
```
|
||||
|
||||
### 4.2 启动与停止(唯一方式;子命令只认 start|stop|status)
|
||||
|
||||
```bash
|
||||
# API:单进程双入口(HTTP 8360 + HTTPS 8361 共用同一 app 状态;lifespan 只进一次)
|
||||
cd /opt/cybergril-hel913/current
|
||||
HEL913_BASE=/opt/cybergril-hel913 bash deploy/hel913-unified/api_ctl.sh start
|
||||
# 健康检查:curl -s http://127.0.0.1:8360/api/health(version=R4-assembly,
|
||||
# semantic_backend=stub;llm.ok=false 是诚实状态——cap=0 且未配网关)
|
||||
|
||||
# 4.2 语音 worker(语音窗口获批后;TTS 9880 先起、面板 8090 可选)
|
||||
# 语音 worker(语音窗口获批后;接线与前置见 §5)
|
||||
HEL913_BASE=/opt/cybergril-hel913 bash deploy/hel913-unified/worker_ctl.sh start
|
||||
# worker 经 PYTHONPATH=current/src 用 agent venv 运行,注册到本机 LiveKit 7880,
|
||||
# 健康口 8082( HEL913_WORKER_HEALTH 可改);只按 logs/worker.pid 停止。
|
||||
|
||||
# 4.3 停止顺序:先 worker 后 API(语音会话先释放,再关统一进程)
|
||||
# 停止顺序:先 worker 后 API(语音会话先释放,再关统一进程)
|
||||
HEL913_BASE=/opt/cybergril-hel913 bash deploy/hel913-unified/worker_ctl.sh stop
|
||||
HEL913_BASE=/opt/cybergril-hel913 bash deploy/hel913-unified/api_ctl.sh stop
|
||||
```
|
||||
|
||||
启停脚本安全口径(收口版,`test_ctl_scripts.sh` 42 项离线替身验证):
|
||||
非法子命令拒绝退出 2,绝不静默当 start;重复 start 拒绝(不丢既有 pid
|
||||
句柄);stop/失败收尾只杀**身份核验通过**(cmdline 含本启动器/模块名且
|
||||
cwd 是本实例目录)的进程,PID 被复用时拒杀并报告;启动健康/注册检查
|
||||
不过时清掉自己刚起的进程、保留日志退出 1;`worker_ctl.sh` 启动前拒绝
|
||||
含未填 `<...>` 占位或解析失败的 `.env`。
|
||||
|
||||
同一数据目录**绝不允许**两个写入实例并存(双入口由 `deploy/voice/serve_dual_8360_8361.py`
|
||||
在同一进程内保证;另起独立 uvicorn 会触发 lifespan 重入 fail-closed)。
|
||||
|
||||
## 5. 备份与保留资料回退
|
||||
## 5. 语音窗口唯一接线(获批窗口才动;默认全 0/未布防)
|
||||
|
||||
浏览器从 HTTPS(8361) 页面连 LiveKit **必须走 wss**(混合内容策略),
|
||||
`voice.yaml` 的 `livekit_url` 因此必须是 wss 桥地址(默认拟 `wss://192.168.200.12:8363`,
|
||||
`bridge_ctl.template.sh` 启停,与 8361 同证书、回环转发 7880)——**不是
|
||||
可选件**;服务器内部(开房/删房/worker 注册)仍走 `livekit_internal` 的
|
||||
本机明文 7880。窗口内各上限的唯一接线:
|
||||
|
||||
| 上限 | 接线(唯一) | 性质 |
|
||||
| --- | --- | --- |
|
||||
| ASR 音频总量 / 每通重连 | `worker/.env` 三项 `CYBERGRIL_ASR_WINDOW_ID/_MAX_AUDIO_SECONDS/_MAX_CONNECT_RETRIES_PER_CALL`(空/0=拒绝一切 ASR;布防值见 `voice-window-arm.template.env`) | 程序硬闸,发送前拒绝(`src/cybergril/voice/asr_usage.py`,逐通落账) |
|
||||
| 每通墙钟/房间寿命 | `voice.yaml` `session_ttl_seconds: 900` + token TTL 300;挂断即删房(失败留账重试) | 程序硬闸 + 到期失效 |
|
||||
| TTS 段数 | `tts_ctl.template.sh` start 时记录 tts.log 起始字节,`grep -c "first chunk"` 对照窗口段数上限 | 监控口径(到顶即人工 force_end;程序不硬闸) |
|
||||
| 窗口总时限 | `force_end.template.sh watch <deadline>` 到点强制收尾(DELETE 全部会话→worker→api→bridge→tts,各按专属句柄);更可靠的等价物是获批后装 systemd timer 调 `now` | 可执行停服,非口头承诺 |
|
||||
|
||||
窗口启动顺序:tts_ctl snapshot→start → bridge_ctl start → 改 `worker/.env`
|
||||
布防三项并 worker_ctl start → api_ctl start(见 §4.2)→ force_end watch
|
||||
挂上。窗口结束(到期/触线/人工):force_end now → 按 `seal_budget_hel879.py`
|
||||
封账归档(**封账不解除**,旧三窗口余额也不结转进新窗)。
|
||||
|
||||
## 6. 备份与保留资料回退
|
||||
|
||||
- **发布/阶段归档**(本包口径,沿用 HEL-896 收口工具,一致性快照):
|
||||
```bash
|
||||
# 停服口径(推荐;目录内 SQLite 一并 checkpoint+逐表核对)
|
||||
systemctl stop <实例> # 或 api_ctl.sh stop
|
||||
bash deploy/hel913-unified/api_ctl.sh stop
|
||||
.venv311/bin/python tools/release_snapshot_hel896.py snapshot \
|
||||
--name <阶段名> --db /opt/cybergril-hel913/data/companion.db \
|
||||
--file /opt/cybergril-hel913/data --out /opt/cybergril-hel913/archives/
|
||||
```
|
||||
产物含逐文件 SHA256、代码精确提交、逐表行数与回退演练;旧归档不删。
|
||||
- **回退**:停服 → 解包快照到新 data 目录(按 rollback_plan 源路径映射)→
|
||||
`current` 切回上一提交(`git checkout <旧head>`)→ 起服务 → `verify` 通过。
|
||||
- **整实例撤销但保留资料**:`api_ctl.sh stop`,data/ 原样保留,systemd 单元
|
||||
disable;重新启用 = 同一 data 目录再 start(epoch 递增、聊天记忆保留,离线
|
||||
验证第 11 组复现)。
|
||||
`current` 切回上一运行包提交(`git checkout <旧head>`)→ 起服务 → `verify` 通过。
|
||||
- **整实例撤销但保留资料**:`api_ctl.sh stop`,data/ 原样保留,重新启用 =
|
||||
同一 data 目录再 start(epoch 递增、聊天记忆保留,离线验证第 11 组复现)。
|
||||
- **CG-009 每日自动备份/用户手动完整导出(R6)尚未实现**,本节只是发布归档,
|
||||
不得冒充 R6 完成。
|
||||
|
||||
## 6. 零真实调用运行准备验证(已执行,34/34)
|
||||
## 7. 零真实调用运行准备验证(已执行,34/34;口径如实)
|
||||
|
||||
在 .12 产品 3.11 venv 对候选 head 树实跑 `verify_offline.py`(进程内 TestClient,
|
||||
零监听、零出站——网关地址重写为 127.0.0.1:1 + provider.stream 出站哨兵双保险):
|
||||
在 .12 产品 3.11 venv 对产品基线树实跑 `verify_offline.py`(进程内
|
||||
TestClient,零监听、零出站——网关地址重写为 127.0.0.1:1 + provider.stream
|
||||
出站哨兵双保险):
|
||||
|
||||
- 包完整性:Python 3.11.16、候选树 import、锁定依赖版本、记忆栈四项缺置如实。
|
||||
- 入口/创建守门:health 诚实(llm.ok=false)、空库 404 无伪造档案、预览本地
|
||||
计算、创建 201、二次创建 409、底色落库与预览一致、persona 在 cap=0 下诚实
|
||||
failed(无编造诠释)。
|
||||
- 包完整性:Python 3.11.16、候选树 import、**4 个关键包版本打印**
|
||||
(fastapi/uvicorn/httpx/pydantic——不是 19 项锁依赖的逐项核对)、记忆栈
|
||||
四项缺置如实。
|
||||
- 入口/创建守门:health 诚实(llm.ok=false)、空库 404 无伪造档案、预览
|
||||
本地计算、创建 201、二次创建 409、底色落库与预览一致、persona 在 cap=0
|
||||
下诚实 failed(无编造诠释)。
|
||||
- 传输:SSE 对话在预算 0 下诚实 `chat.error`,零 provider 出站;失败轮如实
|
||||
落库;同轮重试幂等拒绝。
|
||||
- 日子与回忆:未分享生活服务端裁剪(told=1)、分页形状、未知回执/详情 404。
|
||||
- 日子与回忆:**空库上的**未分享生活服务端裁剪(told=1;未做正反种子对照,
|
||||
不夸成实质权限全覆盖)、分页形状、未知回执/详情 404。
|
||||
- 语音:status 诚实 voice=false;TTS 不可达时开房 503 拒绝(绝不建房);
|
||||
未知会话 DELETE 404。
|
||||
- 重开:epoch=2、身份/关系/聊天保留、无伪造回复。
|
||||
@@ -125,42 +212,121 @@ HEL913_BASE=/opt/cybergril-hel913 bash deploy/hel913-unified/api_ctl.sh stop
|
||||
- worker 接线:agent venv(livekit-agents 1.8.8)下 `import cybergril.voice.worker`
|
||||
通过(只读 import,未启动注册)。
|
||||
|
||||
**预算 0 下只能诚实拒绝的**:一切真实创建诠释/习惯、对话生成、生活事件生成、
|
||||
判定/成长/gist、主动措辞、嵌入、语音开房。`/api/health` 的 200 不代表模型已
|
||||
运行——`llm.ok=false` 才是诚实状态。
|
||||
**预算 0 下只能诚实拒绝的**:一切真实创建诠释/习惯、对话生成、生活事件
|
||||
生成、判定/成长/gist、主动措辞、嵌入、语音开房。`/api/health` 的 200 不代表
|
||||
模型已运行——`llm.ok=false` 才是诚实状态。
|
||||
|
||||
## 7. 真实记忆(Mem0)运行缺项 —— 已核实,未安装
|
||||
## 8. 真实记忆(Mem0)最少安装与接线 —— 完整可审清单(零安装零下载,待批)
|
||||
|
||||
- **服务器 .12 现状(2026-10-29 只读实测)**:产品 `.venv311`(3.11.16)内
|
||||
`mem0 / qdrant_client / fastembed / onnxruntime` 四项均未安装;服务器全盘无
|
||||
mem0 安装、无固定 tarball、无已建轮、无 fastembed 缓存、uv 缓存仅 28K。
|
||||
**没有另一个已准备好的 3.11 兼容环境**;旧 3.10 `hel857-venv`(3.10.12,
|
||||
工作站本地)不能混入 3.11 进程。
|
||||
- **已有实物(工作站本地,未上服务器)**:固定源 `mem0-2c81af3.tar.gz`
|
||||
(sha256 `9dcef930…`,与 `deploy/mem0-stack.lock` 一致,本卡复验);固定源
|
||||
离线构建轮 `mem0ai-2.2.1-py3-none-any.whl`(sha256 `698284b6…`,本卡复验);
|
||||
fastembed 模型缓存 92MB(Qdrant/bge-small-zh-v1.5 + bm25);本地 uv 缓存可
|
||||
### 8.1 现状(2026-10-29 只读实测,收口轮复核沿用)
|
||||
|
||||
- 服务器 .12 产品 `.venv311`(3.11.16)内 `mem0 / qdrant_client /
|
||||
fastembed / onnxruntime` 四项均未安装;服务器全盘无 mem0 安装、无固定
|
||||
tarball、无已建轮、无 fastembed 缓存、uv 缓存仅 28K。**没有另一个已
|
||||
准备好的 3.11 兼容环境**;旧 3.10 `hel857-venv`(工作站)不能混入 3.11
|
||||
进程。
|
||||
- 工作站本地实物(未上服务器):固定源 tarball `mem0-2c81af3.tar.gz`
|
||||
(sha256 `9dcef9303ebcec116eec6739f01b8b35bd24459de6a569686b4d19b9412dda23`,
|
||||
与 `deploy/mem0-stack.lock` 一致)、固定源已建轮
|
||||
`mem0ai-2.2.1-py3-none-any.whl`(sha256
|
||||
`698284b6083ab8b7761454d65876a6d1bb983d278ad21a7bee38d760cb20e9db`)、
|
||||
fastembed 模型缓存 92MB(Qdrant/bge-small-zh-v1.5 + bm25)、uv 缓存可
|
||||
复用 3 轮(greenlet/pillow/truststore cp311)。
|
||||
- **最少安装动作(待一次性批准;本卡零安装零下载)**,唯一入口
|
||||
`deploy/hel895-release-candidate.md` §4:
|
||||
1. tarball 哈希核对(或直接复用已建轮并核对 `698284b6…`);
|
||||
2. 获批窗口内 `pip download --only-binary :all: --implementation cp
|
||||
--python-version 3.11 --platform manylinux2014_x86_64 --abi cp311
|
||||
-r deploy/hel913-unified/mem0-cp311-wheels.txt -d wheels/`(40 项,
|
||||
逐项 sha256 留证;其中 3 项可从工作站缓存离线复用);
|
||||
3. 传输轮目录 + fastembed 缓存(92MB)到服务器;
|
||||
4. `uv pip install --python .venv311/bin/python --no-index --find-links wheels/
|
||||
mem0ai==2.2.1 qdrant-client==1.20.0 fastembed==0.9.1 <40项>`;
|
||||
5. co-import 冒烟 + fastembed cache_dir 指向实例数据目录内缓存拷贝。
|
||||
**空间/影响**:.venv311 增约 300–400MB(3.10 同栈实测 366MB 参考)+ 轮暂存
|
||||
约 150MB + 模型缓存 92MB;首次本地嵌入零下载(缓存就位)。激活语义层仍需
|
||||
B 部分嵌入/提取预算(见 docs/hel913-capability-and-enablement.md §2)。
|
||||
在此之前 `CYBERGRIL_SEMANTIC=stub`,长期检索走词面 FTS,不以 stub 冒充
|
||||
真实 Mem0。
|
||||
|
||||
## 8. 本包不做的事
|
||||
### 8.2 安装目标环境:本实例自己的隔离 venv(不是产品 .venv311)
|
||||
|
||||
**绝不向借用的 `/opt/cybergril-hel879/current/.venv311` 增改任何依赖。**
|
||||
目标环境是 `/opt/cybergril-hel913/venv311`(服务器既有 python3.11 基座
|
||||
新建,3.11.16),装两套东西:产品锁 19 项 + 记忆栈 41 项(40 缺轮 + 固定
|
||||
源 mem0ai 轮)。装好后本实例 API 用它跑(`api_ctl.sh` 里
|
||||
`HEL913_VENV=/opt/cybergril-hel913/venv311/bin/python`),与 hel879 实例
|
||||
彻底隔离;`.venv311` 保持只读借用前的原样(部署后可直接改回借用口径,
|
||||
两者兼容——同一 requirements.lock)。
|
||||
|
||||
### 8.3 一次性批准窗口内的完整命令(逐项哈希留证;任一步失败即停)
|
||||
|
||||
```bash
|
||||
# W0 · 固定源身份核对(零下载;哈希不符立即停,禁用索引同名轮替代)
|
||||
sha256sum <hel857-data>/mem0-2c81af3.tar.gz # 必须等于 9dcef930…2dda23
|
||||
sha256sum <hel857-data>/mem0ai-2.2.1-py3-none-any.whl # 必须等于 698284b6…20e9db
|
||||
|
||||
# W1 · 获批下载窗口(工作站联网执行;cp311/manylinux2014_x86_64 定版)
|
||||
mkdir -p wheels-product wheels-mem0
|
||||
python3 -m pip download --only-binary :all: --implementation cp \
|
||||
--python-version 3.11 --platform manylinux2014_x86_64 --abi cp311 \
|
||||
-r requirements.lock -d wheels-product/ # 产品锁 19 项
|
||||
python3 -m pip download --only-binary :all: --implementation cp \
|
||||
--python-version 3.11 --platform manylinux2014_x86_64 --abi cp311 \
|
||||
-r deploy/hel913-unified/mem0-cp311-wheels.txt -d wheels-mem0/ # 记忆栈 40 项
|
||||
# 其中 greenlet/pillow/truststore 3 项可从工作站 uv 缓存离线复用
|
||||
# (release-artifacts.json 记录),命中即从 wheels-mem0/ 删除同版本再放缓存件
|
||||
cp <hel857-data>/mem0ai-2.2.1-py3-none-any.whl wheels-mem0/
|
||||
( cd wheels-product && sha256sum * > ../wheels-product.sha256 )
|
||||
( cd wheels-mem0 && sha256sum * > ../wheels-mem0.sha256 ) # 逐项留证入库
|
||||
|
||||
# W2 · 传输与落位(scp 到 .12;约 wheels 250–350MB + 模型缓存 92MB)
|
||||
scp -r wheels-product wheels-mem0 <hel857-data>/fastembed-cache root@192.168.200.12:/opt/cybergril-hel913/
|
||||
ssh root@192.168.200.12 'sha256sum -c /opt/cybergril-hel913/wheels-product.sha256 && \
|
||||
sha256sum -c /opt/cybergril-hel913/wheels-mem0.sha256' # 传输后复核
|
||||
|
||||
# W3 · 隔离 venv 创建 + 仅本地轮安装(--no-index 全程,失败即停)
|
||||
ssh root@192.168.200.12
|
||||
python3.11 -m venv /opt/cybergril-hel913/venv311
|
||||
/opt/cybergril-hel913/venv311/bin/python -m pip install --no-index \
|
||||
--find-links /opt/cybergril-hel913/wheels-product -r /opt/cybergril-hel913/current/requirements.lock
|
||||
/opt/cybergril-hel913/venv311/bin/python -m pip install --no-index \
|
||||
--find-links /opt/cybergril-hel913/wheels-mem0 \
|
||||
mem0ai==2.2.1 qdrant-client==1.20.0 fastembed==0.9.1
|
||||
# mem0ai 的安装来源必须是 W0 的固定源码轮(同版本号不同来源不互认)
|
||||
|
||||
# W4 · co-import 冒烟(同进程;失败即停,不降级)
|
||||
cd /opt/cybergril-hel913/current
|
||||
PYTHONPATH=src /opt/cybergril-hel913/venv311/bin/python -c \
|
||||
"import cybergril.api, mem0, qdrant_client, fastembed; print('co-import ok')"
|
||||
|
||||
# W5 · 模型缓存落位(真实本地嵌入零下载)
|
||||
mkdir -p /opt/cybergril-hel913/data/sem
|
||||
cp -a /opt/cybergril-hel913/fastembed-cache /opt/cybergril-hel913/data/sem/fastembed-cache
|
||||
# semantic.yaml 的 fastembed cache_dir 指向上面的目录(见 8.4)
|
||||
|
||||
# W6 · 清理暂存(轮文件传输件用毕即删;哈希清单留档)
|
||||
rm -rf /opt/cybergril-hel913/wheels-product /opt/cybergril-hel913/wheels-mem0 /opt/cybergril-hel913/fastembed-cache
|
||||
```
|
||||
|
||||
**空间/影响(.12 实测口径估)**:`venv311` 成品约 450–550MB(产品 19 项
|
||||
约 120–150MB + 记忆栈约 330–400MB,参照 3.10 同栈实测 366MB)+ 传输暂存
|
||||
约 350MB(W6 删除)+ 模型缓存 92MB(常驻 data/sem)。首次本地嵌入零下载
|
||||
(缓存就位)。**当前不触发任何嵌入**:装完不批 B 预算时
|
||||
`CYBERGRIL_SEMANTIC=stub`,长期检索走词面 FTS,不以 stub 冒充真实 Mem0。
|
||||
|
||||
### 8.4 记忆账本与配置接线(新空用户库续账,不搬测试聊天)
|
||||
|
||||
- `CYBERGRIL_SEMANTIC`(api_ctl.sh 的 `HEL913_SEMANTIC`):`stub`(默认,
|
||||
全链可跑、非语义)→ 批准后 `mem0`(真实)。
|
||||
- 配置:`cp config/semantic.example.yaml /opt/cybergril-hel913/etc/semantic.yaml`,
|
||||
填 `ledger_path=/opt/cybergril-hel913/data/embed_ledger.sqlite3`、
|
||||
`vector_root/history_root=/opt/cybergril-hel913/data/sem/{vec,hist}`、
|
||||
网关三键(与 models.yaml 同源)、`authority` 块。
|
||||
- **权威旧账续账(498 已用 / 原批 500 / 冻结 2 不动)**:把 HEL-857 系列
|
||||
唯一权威嵌入账文件复制为实例 `data/embed_ledger.sqlite3`(只复制账本,
|
||||
**不搬任何测试聊天/向量**——聊天在旧测试库,向量在新库从零生成);
|
||||
`authority` 按 `config/semantic.example.yaml` 算式填
|
||||
`prefix_rows: 181`、`prefix_sha256: <权威账前 181 行逐行摘要,总管按账现值填>`、
|
||||
`min_used: 498`。批准 B 嵌入 180 条后写累计口径
|
||||
`embed_cap: 680`、`embed_reserve: 2`(可用 = 680−498−2 = 180;**禁止**
|
||||
把 180 直接填成 cap、禁止动冻结 2 条;缺/错 authority 在构造前拒绝,
|
||||
指向新空文件重开余额同样被拒——`src/cybergril/memory/semantic.py`
|
||||
`verify_ledger_authority`)。
|
||||
- **不把旧实验余额当新用量**:39/60(HEL-857 真实请求旧账)与旧三窗口
|
||||
余额一律不结转;用户实例的 LLM/请求账从 0 起记(自己的 SQLite 日账)。
|
||||
- **副作用如实分开**:真实 embed(写入向量库+权威账)、SDK 内部提取 LLM
|
||||
(`llm_ops` 独立 cap + 统一请求闸 "semantic" 类)、co-import 冒烟(零
|
||||
调用,只 import)——三者互不冒充;当前阶段三者全部 0。
|
||||
|
||||
## 9. 本包不做的事
|
||||
|
||||
不部署、不监听现网端口、不恢复 9880/8090/836x/8082、不触 4080、不下载任何
|
||||
依赖/模型/浏览器、不改模型/认证/运行时绑定、不合并 PR、不替换正式界面、
|
||||
8300/8310/8320/8350 与既有资料不动、8340/ComfyUI 保持停机。旧三次测试窗口
|
||||
余额不结转;一切提额是待批准建议。
|
||||
8300/8310/8320/8350 与既有资料不动、8340/ComfyUI 保持停机、不向
|
||||
`/opt/cybergril-hel879/current/.venv311` 增改依赖。旧三次测试窗口余额不
|
||||
结转;一切提额、安装、部署都是待批准建议。
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
# HEL-913 统一体验运行包 · 统一实例 API 启停(单进程 HTTP+HTTPS 双入口)
|
||||
#
|
||||
# 与 HEL-910 的 api_ctl.sh 同构,去掉一次性路径硬编码:实例根、端口、证书、
|
||||
# 解释器全部可用环境变量覆盖。启动器 deploy/voice/serve_dual_8360_8361.py
|
||||
# 保证 HTTP 与 HTTPS 共用同一 API 进程/同一份状态(lifespan 只进一次)。
|
||||
# 启动器 deploy/voice/serve_dual_8360_8361.py 保证 HTTP 与 HTTPS 共用同一
|
||||
# API 进程/同一份状态(lifespan 只进一次)。本脚本只做本实例常规启停安全:
|
||||
# - 子命令只认 start|stop|status,其他一律拒绝退出 2(不会静默当 start);
|
||||
# - start 前核对 pid 句柄:本实例已在跑 → 拒绝重复 start(不覆盖句柄);
|
||||
# 句柄 pid 活着但不属于本实例(PID 复用)→ 拒绝动手,提示人工处理;
|
||||
# - stop/start 失败收尾只杀经身份核验的进程(/proc/<pid> 的 cmdline 含
|
||||
# 本启动器且 cwd 是本实例代码目录),身份不符一律不杀;
|
||||
# - start 健康检查不过 → 清掉自己刚起的进程、保留日志、退出 1。
|
||||
#
|
||||
# 用法: [ENV=..] bash deploy/hel913-unified/api_ctl.sh start|stop|status
|
||||
# 环境变量(默认值按部署说明的实例布局):
|
||||
@@ -22,42 +27,114 @@ CERT=${HEL913_CERT:-/opt/cybergril-voice-certs/cybergril-voice.pem}
|
||||
KEY=${HEL913_KEY:-/opt/cybergril-voice-certs/cybergril-voice.key}
|
||||
LOG=$BASE/logs/api.log
|
||||
PIDF=$BASE/logs/api.pid
|
||||
PAT="cybergril.*serve_dual"
|
||||
MARKER="serve_dual_8360_8361.py"
|
||||
|
||||
usage() { echo "usage: [ENV=..] bash $0 start|stop|status" >&2; exit 2; }
|
||||
|
||||
# 进程身份核验:pid 存活、cmdline 含本启动器、cwd 是本实例代码目录。
|
||||
# 任一不满足即视为“不是我们的进程”(含 PID 被系统复用),一律不动它。
|
||||
ours() {
|
||||
local p=$1 cmd cw
|
||||
case "$p" in ''|*[!0-9]*) return 1 ;; esac
|
||||
[ "$p" != "$$" ] || return 1
|
||||
kill -0 "$p" 2>/dev/null || return 1
|
||||
cmd=$(tr '\0' ' ' < "/proc/$p/cmdline" 2>/dev/null) || return 1
|
||||
cw=$(readlink "/proc/$p/cwd" 2>/dev/null) || return 1
|
||||
case "$cmd" in *"$MARKER"*) ;; *) return 1 ;; esac
|
||||
[ "$cw" = "$CODE" ] || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
pidfile_pid() { [ -f "$PIDF" ] && cat "$PIDF" 2>/dev/null; }
|
||||
|
||||
stop() {
|
||||
if [ -f "$PIDF" ]; then
|
||||
P=$(cat "$PIDF")
|
||||
if [ "$P" != "$$" ] && kill -0 "$P" 2>/dev/null; then kill "$P"; sleep 3; fi
|
||||
if [ "$P" != "$$" ] && kill -0 "$P" 2>/dev/null; then kill -9 "$P"; fi
|
||||
rm -f "$PIDF"
|
||||
local p
|
||||
p=$(pidfile_pid)
|
||||
if [ -z "$p" ]; then
|
||||
echo "api not running (no pid file)"
|
||||
return 0
|
||||
fi
|
||||
if kill -0 "$p" 2>/dev/null && ! ours "$p"; then
|
||||
echo "REFUSED: pid $p is alive but is NOT this instance's api (pid reuse?) — not killing; resolve $PIDF manually" >&2
|
||||
return 1
|
||||
fi
|
||||
if ours "$p"; then
|
||||
kill "$p"
|
||||
sleep 3
|
||||
if ours "$p"; then kill -9 "$p"; sleep 1; fi
|
||||
fi
|
||||
rm -f "$PIDF"
|
||||
echo "api stopped"
|
||||
return 0
|
||||
}
|
||||
|
||||
start() {
|
||||
local p
|
||||
p=$(pidfile_pid)
|
||||
if [ -n "$p" ] && kill -0 "$p" 2>/dev/null; then
|
||||
if ours "$p"; then
|
||||
echo "REFUSED: api already running (pid $p) — stop first" >&2
|
||||
else
|
||||
echo "REFUSED: pid file has live pid $p that is not this instance's api (pid reuse?) — resolve $PIDF manually" >&2
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
rm -f "$PIDF" # 死句柄:清掉再起
|
||||
[ -d "$CODE" ] || { echo "REFUSED: code dir missing: $CODE" >&2; exit 1; }
|
||||
[ -x "$VENV" ] || { echo "REFUSED: venv python not executable: $VENV" >&2; exit 1; }
|
||||
[ -r "$CERT" ] && [ -r "$KEY" ] || { echo "REFUSED: cert/key not readable ($CERT / $KEY)" >&2; exit 1; }
|
||||
mkdir -p "$BASE/logs" "$BASE/data"
|
||||
cd "$CODE" || exit 1
|
||||
set -a
|
||||
export CYBERGRIL_DB=$BASE/data/companion.db
|
||||
export CYBERGRIL_SEMANTIC=${HEL913_SEMANTIC:-stub}
|
||||
export CYBERGRIL_R2_ENABLED=${HEL913_R2:-1}
|
||||
export CYBERGRIL_MODELS=$BASE/etc/models.yaml
|
||||
export CYBERGRIL_VOICE_CONFIG=$BASE/etc/voice.yaml
|
||||
export CYBERGRIL_WEB=$CODE/web/dist
|
||||
export PYTHONPATH=$CODE/src
|
||||
set +a
|
||||
nohup "$VENV" deploy/voice/serve_dual_8360_8361.py \
|
||||
--http-port "$HTTP" --https-port "$HTTPS" --cert "$CERT" --key "$KEY" \
|
||||
> "$LOG" 2>&1 &
|
||||
p=$!
|
||||
echo "$p" > "$PIDF"
|
||||
echo "api starting (pid $p) http=$HTTP https=$HTTPS"
|
||||
sleep 6
|
||||
if curl -s --max-time 3 "http://127.0.0.1:$HTTP/api/health" >/dev/null \
|
||||
&& curl -sk --max-time 3 "https://127.0.0.1:$HTTPS/api/health" >/dev/null; then
|
||||
echo "OK: $HTTP + $HTTPS healthy"
|
||||
return 0
|
||||
fi
|
||||
echo "FAIL: health check did not pass — full log kept at $LOG; tail:" >&2
|
||||
tail -20 "$LOG" >&2
|
||||
# 失败收尾:只清自己刚起的这个进程(身份核验),日志保留
|
||||
if ours "$p"; then
|
||||
kill "$p"; sleep 2
|
||||
ours "$p" && kill -9 "$p"
|
||||
fi
|
||||
rm -f "$PIDF"
|
||||
echo "cleaned up failed start (log kept: $LOG)" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
status() {
|
||||
local p
|
||||
p=$(pidfile_pid)
|
||||
if [ -n "$p" ]; then
|
||||
if ours "$p"; then echo "running pid $p (identity verified)"
|
||||
elif kill -0 "$p" 2>/dev/null; then echo "pid $p alive but NOT ours (stale pid file?)"
|
||||
else echo "pid $p not alive (stale pid file)"; fi
|
||||
else
|
||||
echo "no pid file"
|
||||
fi
|
||||
curl -s --max-time 3 "http://127.0.0.1:$HTTP/api/health" && echo " <- health" \
|
||||
|| echo "health not answering"
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
stop) stop; exit 0 ;;
|
||||
status)
|
||||
[ -f "$PIDF" ] && { P=$(cat "$PIDF"); kill -0 "$P" 2>/dev/null && echo "running pid $P" || echo "pid $P not alive"; }
|
||||
curl -s --max-time 3 "http://127.0.0.1:$HTTP/api/health" && echo " <- health" || echo "health not answering"
|
||||
exit 0 ;;
|
||||
start) start ;;
|
||||
stop) stop ;;
|
||||
status) status ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
|
||||
stop
|
||||
cd "$CODE"
|
||||
set -a
|
||||
export CYBERGRIL_DB=$BASE/data/companion.db
|
||||
export CYBERGRIL_SEMANTIC=${HEL913_SEMANTIC:-stub}
|
||||
export CYBERGRIL_R2_ENABLED=${HEL913_R2:-1}
|
||||
export CYBERGRIL_MODELS=$BASE/etc/models.yaml
|
||||
export CYBERGRIL_VOICE_CONFIG=$BASE/etc/voice.yaml
|
||||
export CYBERGRIL_WEB=$CODE/web/dist
|
||||
export PYTHONPATH=$CODE/src
|
||||
set +a
|
||||
nohup "$VENV" deploy/voice/serve_dual_8360_8361.py \
|
||||
--http-port "$HTTP" --https-port "$HTTPS" --cert "$CERT" --key "$KEY" \
|
||||
> "$LOG" 2>&1 &
|
||||
echo $! > "$PIDF"
|
||||
echo "api starting (pid $(cat "$PIDF")) http=$HTTP https=$HTTPS"
|
||||
sleep 6
|
||||
curl -s --max-time 3 "http://127.0.0.1:$HTTP/api/health" >/dev/null && echo "OK: $HTTP healthy" || { echo "FAIL:"; tail -20 "$LOG"; exit 1; }
|
||||
curl -sk --max-time 3 "https://127.0.0.1:$HTTPS/api/health" >/dev/null && echo "OK: $HTTPS healthy" || { echo "FAIL $HTTPS:"; tail -20 "$LOG"; exit 1; }
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env bash
|
||||
# HEL-913 运行包 · wss TLS 桥启停模板(8363 → 127.0.0.1:7880;脱敏待批件)
|
||||
#
|
||||
# 浏览器从 HTTPS(8361) 页面连 LiveKit 必须走 wss(混合内容策略),本桥在新
|
||||
# 端口终结 TLS 并只向回环 7880 转发(字节级,协议无关;WebRTC 媒体面不经
|
||||
# 本桥)。与 8361 同一张自签证书。改编自 HEL-910 已实测 bridge_ctl.sh;
|
||||
# 本文件默认不运行,获批语音窗口才使用。子命令只认 start|stop|status。
|
||||
#
|
||||
# 用法: [ENV=..] bash bridge_ctl.template.sh start|stop|status
|
||||
# 环境变量: HEL913_BASE / HEL913_BRIDGE_PORT(8363) / HEL913_CERT / HEL913_KEY
|
||||
set -u
|
||||
BASE=${HEL913_BASE:-/opt/cybergril-hel913}
|
||||
PORT=${HEL913_BRIDGE_PORT:-8363}
|
||||
CERT=${HEL913_CERT:-/opt/cybergril-voice-certs/cybergril-voice.pem}
|
||||
KEY=${HEL913_KEY:-/opt/cybergril-voice-certs/cybergril-voice.key}
|
||||
LOG=$BASE/logs/bridge.log
|
||||
PIDF=$BASE/logs/bridge.pid
|
||||
MARKER="wss_bridge.example.py"
|
||||
|
||||
usage() { echo "usage: [ENV=..] bash $0 start|stop|status" >&2; exit 2; }
|
||||
|
||||
ours() {
|
||||
local p=$1 cmd cw
|
||||
case "$p" in ''|*[!0-9]*) return 1 ;; esac
|
||||
[ "$p" != "$$" ] || return 1
|
||||
kill -0 "$p" 2>/dev/null || return 1
|
||||
cmd=$(tr '\0' ' ' < "/proc/$p/cmdline" 2>/dev/null) || return 1
|
||||
cw=$(readlink "/proc/$p/cwd" 2>/dev/null) || return 1
|
||||
case "$cmd" in *"$MARKER"*) ;; *) return 1 ;; esac
|
||||
[ "$cw" = "$BASE/current/deploy/voice" ] || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
pidfile_pid() { [ -f "$PIDF" ] && cat "$PIDF" 2>/dev/null; }
|
||||
|
||||
stop() {
|
||||
local p
|
||||
p=$(pidfile_pid)
|
||||
if [ -z "$p" ]; then echo "bridge not running (no pid file)"; return 0; fi
|
||||
if kill -0 "$p" 2>/dev/null && ! ours "$p"; then
|
||||
echo "REFUSED: pid $p alive but not this bridge (pid reuse?) — not killing; resolve $PIDF manually" >&2
|
||||
return 1
|
||||
fi
|
||||
if ours "$p"; then kill "$p"; sleep 2; ours "$p" && kill -9 "$p"; fi
|
||||
rm -f "$PIDF"
|
||||
echo "bridge stopped"
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
stop) stop; exit $? ;;
|
||||
status)
|
||||
p=$(pidfile_pid)
|
||||
if [ -n "$p" ]; then
|
||||
ours "$p" && echo "running pid $p (identity verified)" \
|
||||
|| { kill -0 "$p" 2>/dev/null && echo "pid $p alive but NOT ours" || echo "pid $p not alive (stale)"; }
|
||||
else
|
||||
echo "no pid file"
|
||||
fi
|
||||
exit 0 ;;
|
||||
esac
|
||||
|
||||
p=$(pidfile_pid)
|
||||
if [ -n "$p" ] && kill -0 "$p" 2>/dev/null; then
|
||||
echo "REFUSED: bridge already running (pid $p)" >&2; exit 1
|
||||
fi
|
||||
rm -f "$PIDF"
|
||||
[ -r "$CERT" ] && [ -r "$KEY" ] || { echo "REFUSED: cert/key not readable" >&2; exit 1; }
|
||||
cd "$BASE/current/deploy/voice" || exit 1
|
||||
nohup /usr/bin/python3 wss_bridge.example.py \
|
||||
--listen "0.0.0.0:$PORT" --upstream 127.0.0.1:7880 \
|
||||
--cert "$CERT" --key "$KEY" > "$LOG" 2>&1 &
|
||||
echo $! > "$PIDF"
|
||||
echo "bridge starting (pid $(cat "$PIDF")) on :$PORT"
|
||||
sleep 3
|
||||
timeout 8 openssl s_client -connect "127.0.0.1:$PORT" -servername 192.168.200.12 </dev/null 2>/dev/null \
|
||||
| grep -q "TLSv1.3" && echo "OK: bridge TLS up" \
|
||||
|| { echo "WARN: TLS probe inconclusive — check $LOG"; tail -5 "$LOG"; }
|
||||
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env bash
|
||||
# HEL-913 运行包 · 窗口到期强制收尾模板(脱敏待批件;默认不布防)
|
||||
#
|
||||
# 用途:获批体验/语音窗口到截止时点的**可执行**停服与封窗:先经统一实例
|
||||
# API 逐个 DELETE 本实例房间(欠清理的房间会留在登记账重试),再按专属
|
||||
# pid 句柄停 worker → api → wss 桥 → 共享 TTS(都不是我们的就如实报告,
|
||||
# 绝不按进程名/端口扫杀,绝不触碰 8300/8310/8320/8350、7880/7881、10095、
|
||||
# 8081 等共享服务)。改编自 HEL-910 已实测 force_end.sh/watchdog.sh。
|
||||
#
|
||||
# 用法:
|
||||
# bash force_end.template.sh now # 立即收尾(幂等,可重复)
|
||||
# bash force_end.template.sh watch <epoch秒> # 到点自动收尾(受监督后台任务;
|
||||
# # 更可靠的等价物是获批后装
|
||||
# # systemd timer 调本脚本 now)
|
||||
# 环境变量: HEL913_BASE / HEL913_HTTP(8360)
|
||||
set -u
|
||||
BASE=${HEL913_BASE:-/opt/cybergril-hel913}
|
||||
HTTP=${HEL913_HTTP:-8360}
|
||||
PKG=$BASE/current/deploy/hel913-unified
|
||||
LOG=$BASE/logs/force_end.log
|
||||
|
||||
usage() { echo "usage: [ENV=..] bash $0 now|watch <deadline_epoch_seconds>" >&2; exit 2; }
|
||||
|
||||
force_end() {
|
||||
ts() { date -u +%FT%TZ; }
|
||||
{
|
||||
echo "[$(ts)] force_end begin"
|
||||
# 1) 结清本实例房间(DELETE 走统一实例所有者路径;失败房间留账重试)
|
||||
for sid in $(python3 - "$BASE/data" <<'EOF' 2>/dev/null
|
||||
import json, sys, pathlib
|
||||
p = pathlib.Path(sys.argv[1]) / "companion-voice-sessions.json"
|
||||
try:
|
||||
d = json.loads(p.read_text())
|
||||
except Exception:
|
||||
raise SystemExit
|
||||
state = d.get("state", d)
|
||||
def walk(o):
|
||||
if isinstance(o, dict):
|
||||
for k, v in o.items():
|
||||
if k in ("sessions", "active") and isinstance(v, dict):
|
||||
for sid, sess in v.items():
|
||||
print(sid)
|
||||
else:
|
||||
walk(v)
|
||||
elif isinstance(o, list):
|
||||
for i in o:
|
||||
walk(i)
|
||||
walk(state)
|
||||
EOF
|
||||
); do
|
||||
code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 8 -X DELETE "http://127.0.0.1:$HTTP/api/voice/session/$sid" || echo err)
|
||||
echo "[$(ts)] DELETE session $sid -> $code"
|
||||
done
|
||||
# 2) 按专属句柄逐个停(每步幂等;不是我们的如实报告)
|
||||
bash "$PKG/worker_ctl.sh" stop 2>&1 | sed 's/^/ worker: /'
|
||||
bash "$PKG/api_ctl.sh" stop 2>&1 | sed 's/^/ api: /'
|
||||
bash "$PKG/bridge_ctl.template.sh" stop 2>&1 | sed 's/^/ bridge: /'
|
||||
bash "$PKG/tts_ctl.template.sh" stop 2>&1 | sed 's/^/ tts: /'
|
||||
echo "[$(ts)] force_end done(封账归档另由 seal_budget_hel879.py 按账执行,封账不解除)"
|
||||
} >> "$LOG" 2>&1
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
now) force_end ;;
|
||||
watch)
|
||||
DL=${2:?deadline epoch seconds required}
|
||||
echo "[$(date -u +%FT%TZ)] watch start, deadline $(date -u -d "@$DL" +%FT%TZ) (pid $$)" >> "$LOG"
|
||||
while [ "$(date +%s)" -lt "$DL" ]; do sleep 30; done
|
||||
echo "[$(date -u +%FT%TZ)] DEADLINE REACHED — force end" >> "$LOG"
|
||||
force_end
|
||||
;;
|
||||
*) usage ;;
|
||||
esac
|
||||
@@ -1,20 +1,23 @@
|
||||
{
|
||||
"task": "HEL-913",
|
||||
"head": "4a38106eef21c43ba24ab7d07992b1bfe539137d",
|
||||
"product_baseline_head": "4a38106eef21c43ba24ab7d07992b1bfe539137d",
|
||||
"package_head": "运行包提交 = 本文件所在分支 tip(交付评论给出精确 hash;本文件无法写死自身提交)。部署照抄入口是运行包提交,只 checkout 4a38106 会没有 deploy/hel913-unified/",
|
||||
"package_only_change_check": "git diff --stat 4a38106 <package_head> -- src web config tools tests 必须为空(运行包只动 deploy/hel913-unified 与 docs)",
|
||||
"branch": "agent/2/8e99cc2cc592",
|
||||
"review": "HEL-912 01a187e8-1058-7a2d-84e7-bd1896f212cb passed, no must-fix items",
|
||||
"requirements_lock": "requirements.lock (19 pinned, Python 3.11.16 verified)",
|
||||
"review": "HEL-912 01a187e8-1058-7a2d-84e7-bd1896f212cb passed, no must-fix items (product baseline)",
|
||||
"requirements_lock": "requirements.lock (19 pinned, Python 3.11.16 verified; offline verify printed 4 key package versions only — not a per-item lock audit)",
|
||||
"web_dist_reuse": {
|
||||
"source": "/opt/cybergril-hel910/current/web/dist (REVISION 958c6962fb1f2a4462a6df794d893aee1fcb0667)",
|
||||
"justification": "git diff 958c696 4a38106 -- web/ is empty",
|
||||
"manifest": "deploy/hel913-unified/dist-manifest.json (8 files, sha256 measured on .12 2026-10-29)"
|
||||
},
|
||||
"environments": {
|
||||
"api_python": "/opt/cybergril-hel879/current/.venv311 (Python 3.11.16)",
|
||||
"api_python_default": "/opt/cybergril-hel879/current/.venv311 (Python 3.11.16) — borrow-run only, NEVER install into it",
|
||||
"api_python_after_mem0": "/opt/cybergril-hel913/venv311 — isolated instance venv created only inside the approved one-shot window (README §8)",
|
||||
"worker_python": "/opt/voice-agent/agent/venv (livekit-agents 1.8.8)",
|
||||
"certs": "/opt/cybergril-voice-certs/cybergril-voice.{pem,key}",
|
||||
"livekit": "ws://127.0.0.1:7880 (standing)",
|
||||
"tts_panel": "9880/8090 stopped until approved window"
|
||||
"certs": "/opt/cybergril-voice-certs/cybergril-voice.{pem,key} (shared by 8361 and wss bridge 8363)",
|
||||
"livekit": "ws://127.0.0.1:7880 internal (standing); browser MUST use wss bridge (8363) — not optional from HTTPS pages",
|
||||
"tts_panel_bridge": "9880/8090/8363 only inside approved voice windows (README §5); stopped otherwise"
|
||||
},
|
||||
"package_files": [
|
||||
"deploy/hel913-unified/README.md",
|
||||
@@ -23,20 +26,34 @@
|
||||
"deploy/hel913-unified/models.template.yaml",
|
||||
"deploy/hel913-unified/voice.template.yaml",
|
||||
"deploy/hel913-unified/worker.env.template",
|
||||
"deploy/hel913-unified/voice-window-arm.template.env",
|
||||
"deploy/hel913-unified/api_ctl.sh",
|
||||
"deploy/hel913-unified/worker_ctl.sh",
|
||||
"deploy/hel913-unified/bridge_ctl.template.sh",
|
||||
"deploy/hel913-unified/tts_ctl.template.sh",
|
||||
"deploy/hel913-unified/force_end.template.sh",
|
||||
"deploy/hel913-unified/verify_offline.py",
|
||||
"deploy/hel913-unified/test_ctl_scripts.sh",
|
||||
"deploy/hel913-unified/mem0-cp311-wheels.txt",
|
||||
"docs/rework/hel913/verify-offline-run.txt",
|
||||
"docs/rework/hel913/ctl-checks-run.txt",
|
||||
"docs/hel913-capability-and-enablement.md"
|
||||
],
|
||||
"offline_verification": {
|
||||
"where": ".12 product .venv311, candidate tree at /tmp/hel913-verify (cleaned after run)",
|
||||
"where": ".12 product .venv311, candidate tree at /tmp/hel913-verify (cleaned after run); re-run by manager: 34/34 passed, dist 8-file hashes match",
|
||||
"result": "34/34 checks passed; worker import ok under livekit-agents 1.8.8",
|
||||
"zero_real_calls": "models base_url rewritten to 127.0.0.1:1 + provider.stream outbound sentinel; no listening sockets; no rooms; no gateway contact"
|
||||
"zero_real_calls": "models base_url rewritten to 127.0.0.1:1 + provider.stream outbound sentinel; no listening sockets; no rooms; no gateway contact",
|
||||
"scope_limits": "deps check printed 4 key versions only; unshared-life trimming verified on an empty DB (told=1) without positive/negative seed contrast — not claimed as full dependency or permission coverage",
|
||||
"ctl_scripts": "test_ctl_scripts.sh 42/42 offline stub checks (invalid subcommand, duplicate start, pid-reuse refusal, failed-start cleanup, .env gating, templates default 0)"
|
||||
},
|
||||
"voice_window_wiring": {
|
||||
"asr_hard_gate": "worker/.env CYBERGRIL_ASR_WINDOW_ID/_MAX_AUDIO_SECONDS/_MAX_CONNECT_RETRIES_PER_CALL (empty/0 = deny all ASR)",
|
||||
"room_lifetime": "voice.yaml session_ttl_seconds=900 + token_ttl 300 + delete-on-hangup (bounded cleanup ledger)",
|
||||
"tts_segments": "monitored via tts.log first-chunk count since window start (tts_ctl.template.sh records start byte); hard stop = window deadline",
|
||||
"deadline": "force_end.template.sh now|watch <epoch> (DELETE sessions -> worker -> api -> bridge -> tts, pid-handle stops only)"
|
||||
},
|
||||
"memory_gap": {
|
||||
"server_venv311": "mem0/qdrant_client/fastembed/onnxruntime all absent (verified 2026-10-29)",
|
||||
"server_venv311": "mem0/qdrant_client/fastembed/onnxruntime all absent (verified 2026-10-29; never install into this borrowed venv)",
|
||||
"no_other_311_env_on_server": true,
|
||||
"local_artifacts": {
|
||||
"mem0-2c81af3.tar.gz": "9dcef9303ebcec116eec6739f01b8b35bd24459de6a569686b4d19b9412dda23",
|
||||
@@ -44,7 +61,9 @@
|
||||
"fastembed_cache": "92MB (Qdrant/bge-small-zh-v1.5 + bm25)",
|
||||
"hel857_venv": "Python 3.10.12 — must not mix into 3.11 process"
|
||||
},
|
||||
"minimal_install": "deploy/hel913-unified/mem0-cp311-wheels.txt (40 wheels, one approved window) + wheel transfer + --no-index install + co-import; entry remains deploy/hel895-release-candidate.md §4"
|
||||
"install_target": "isolated /opt/cybergril-hel913/venv311 (python3.11 base + product lock 19 wheels + mem0 stack 40 wheels + fixed-source mem0ai wheel; all --no-index; complete auditable steps in README §8.3 with per-file sha256 evidence and fail-stop)",
|
||||
"ledger_continuation": "authoritative embed ledger copied to instance data/embed_ledger.sqlite3 (ledger only — no test chats/vectors moved); authority prefix_rows=181, prefix_sha256 by manager, min_used=498, embed_cap=680 cumulative formula, frozen 2 untouched; 39/60 and old window balances never carried over"
|
||||
},
|
||||
"boundaries": "not deployed; nothing listening; caps all 0; no PR; existing instances and data untouched; no downloads this card"
|
||||
"enablement_doc": "docs/hel913-capability-and-enablement.md §2 — single consistent pending-approval proposal: A/B/C separate accounts, all awaiting approval (manager does not self-approve A), B voice = 3 calls x <=10min = <=1800s ASR hard gate with per-cap consequences and executable window end, B/C boundary fixed",
|
||||
"boundaries": "not deployed; nothing listening; caps all 0; no PR; existing instances and data untouched; no downloads this card; protected venvs untouched"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
#!/usr/bin/env bash
|
||||
# HEL-913 运行包 · 启停脚本离线替身检查(零真实服务、零真实端口、零出站)
|
||||
#
|
||||
# 用离线替身(stub 解释器 = 只休眠的脚本)与静态检查验证收口后的常规启停
|
||||
# 安全:非法子命令拒绝、重复 start 拒绝、stop 的 PID 复用防护、启动失败
|
||||
# 收尾清理、.env 占位/解析守门。不启动真实 API/worker/共享服务,不监听
|
||||
# 任何端口(curl 只连本机高位死端口,必然失败,正是失败路径所需的输入)。
|
||||
#
|
||||
# 用法: bash deploy/hel913-unified/test_ctl_scripts.sh (在检出根目录)
|
||||
set -u
|
||||
PKG=$(cd "$(dirname "$0")" && pwd)
|
||||
ROOT=$(cd "$PKG/../.." && pwd)
|
||||
TMP=$(mktemp -d /tmp/hel913-ctl-test.XXXXXX)
|
||||
PASS=0; FAIL=0
|
||||
cleanup() { rm -rf "$TMP"; }
|
||||
trap cleanup EXIT
|
||||
|
||||
ok() { PASS=$((PASS+1)); echo "PASS $1"; }
|
||||
bad() { FAIL=$((FAIL+1)); echo "FAIL $1"; }
|
||||
expect_rc() { # expect_rc <want> <got> <label>
|
||||
[ "$2" = "$1" ] && ok "$3" || bad "$3 (want rc=$1 got rc=$2)"
|
||||
}
|
||||
|
||||
# ---- S1. 静态:语法 + 包文件齐全 ----
|
||||
for f in api_ctl.sh worker_ctl.sh bridge_ctl.template.sh tts_ctl.template.sh force_end.template.sh; do
|
||||
bash -n "$PKG/$f" 2>/dev/null && ok "syntax $f" || bad "syntax $f"
|
||||
done
|
||||
for f in README.md manifest.json dist-manifest.json models.template.yaml voice.template.yaml \
|
||||
worker.env.template verify_offline.py mem0-cp311-wheels.txt \
|
||||
voice-window-arm.template.env test_ctl_scripts.sh; do
|
||||
[ -f "$PKG/$f" ] && ok "package file $f" || bad "package file $f missing"
|
||||
done
|
||||
|
||||
# ---- 沙盒实例布局(镜像 README §4 的目标布局) ----
|
||||
BASE=$TMP/inst
|
||||
mkdir -p "$BASE/current" "$BASE/worker" "$BASE/etc" "$BASE/data" "$BASE/logs"
|
||||
CODE=$BASE/current; WDIR=$BASE/worker
|
||||
touch "$BASE/etc/models.yaml" "$BASE/etc/voice.yaml"
|
||||
printf 'dummy cert\n' > "$TMP/c.pem"; printf 'dummy key\n' > "$TMP/c.key"
|
||||
|
||||
# stub 解释器:保持 argv 不变(cmdline 保留 marker),留一行输出后休眠
|
||||
STUB=$TMP/stub-python
|
||||
printf '#!/usr/bin/env bash\necho "stub alive pid=$$ argv=$*" >&2\nsleep 600\n' > "$STUB"; chmod +x "$STUB"
|
||||
|
||||
HTTP=53881; HTTPS=53882
|
||||
API_ENV="HEL913_BASE=$BASE HEL913_HTTP=$HTTP HEL913_HTTPS=$HTTPS HEL913_VENV=$STUB HEL913_CERT=$TMP/c.pem HEL913_KEY=$TMP/c.key"
|
||||
|
||||
alive_marker() { pgrep -f "$1" | while read -r p; do [ -d "/proc/$p" ] && echo "$p"; done; }
|
||||
|
||||
# ---- S2. 非法子命令拒绝(不静默当 start) ----
|
||||
env $API_ENV bash "$PKG/api_ctl.sh" bogus >/dev/null 2>&1; expect_rc 2 $? "api_ctl invalid subcommand refused (rc=2)"
|
||||
[ ! -f "$BASE/logs/api.pid" ] && ok "api_ctl invalid subcommand started nothing" || bad "api_ctl invalid subcommand left a pid file"
|
||||
|
||||
env HEL913_BASE=$BASE HEL913_AGENT_VENV=$STUB bash "$PKG/worker_ctl.sh" frobnicate >/dev/null 2>&1
|
||||
expect_rc 2 $? "worker_ctl invalid subcommand refused (rc=2)"
|
||||
[ ! -f "$BASE/logs/worker.pid" ] && ok "worker_ctl invalid subcommand started nothing" || bad "worker_ctl invalid subcommand left a pid file"
|
||||
|
||||
# ---- S3. api 启动失败收尾:健康不过 → 清自己、留日志、rc=1 ----
|
||||
env $API_ENV bash "$PKG/api_ctl.sh" start >/dev/null 2>&1; expect_rc 1 $? "api_ctl failed start exits 1"
|
||||
[ ! -f "$BASE/logs/api.pid" ] && ok "api_ctl failed start removed pid file" || bad "api_ctl failed start left pid file"
|
||||
[ -s "$BASE/logs/api.log" ] && ok "api_ctl failed start kept log" || bad "api_ctl failed start lost log"
|
||||
sleep 1
|
||||
N=$(alive_marker "$STUB.*serve_dual_8360_8361" | wc -l)
|
||||
[ "$N" = "0" ] && ok "api_ctl failed start left no stub process" || bad "api_ctl failed start left $N stub process(es)"
|
||||
|
||||
# ---- S4. api 重复 start 拒绝(活进程 + 有效句柄) ----
|
||||
( cd "$CODE" && nohup "$STUB" deploy/voice/serve_dual_8360_8361.py --http-port $HTTP --https-port $HTTPS > "$BASE/logs/api.log" 2>&1 & echo $! > "$BASE/logs/api.pid" )
|
||||
LIVEPID=$(cat "$BASE/logs/api.pid")
|
||||
kill -0 "$LIVEPID" 2>/dev/null && ok "stub api process running (pid $LIVEPID)" || bad "stub api process failed to start"
|
||||
env $API_ENV bash "$PKG/api_ctl.sh" start >/dev/null 2>&1; expect_rc 1 $? "api_ctl duplicate start refused (rc=1)"
|
||||
[ "$(cat "$BASE/logs/api.pid" 2>/dev/null)" = "$LIVEPID" ] && ok "api_ctl duplicate start kept original handle" || bad "api_ctl duplicate start overwrote handle"
|
||||
kill "$LIVEPID" 2>/dev/null; wait 2>/dev/null
|
||||
|
||||
# ---- S5. api stop 的 PID 复用防护:活 pid 但身份不符 → 拒杀 ----
|
||||
sleep 600 & UNRELATED=$!
|
||||
echo "$UNRELATED" > "$BASE/logs/api.pid"
|
||||
env $API_ENV bash "$PKG/api_ctl.sh" stop >/dev/null 2>&1; expect_rc 1 $? "api_ctl stop refused reused pid (rc=1)"
|
||||
kill -0 "$UNRELATED" 2>/dev/null && ok "unrelated process untouched" || bad "api_ctl stop killed an unrelated process!"
|
||||
kill "$UNRELATED" 2>/dev/null; wait 2>/dev/null
|
||||
rm -f "$BASE/logs/api.pid"
|
||||
|
||||
# ---- S6. api stop 死句柄:直接清 ----
|
||||
echo 999999999 > "$BASE/logs/api.pid"
|
||||
env $API_ENV bash "$PKG/api_ctl.sh" stop >/dev/null 2>&1; expect_rc 0 $? "api_ctl stop with dead pid exits 0"
|
||||
[ ! -f "$BASE/logs/api.pid" ] && ok "api_ctl stop removed stale pid file" || bad "api_ctl stop kept stale pid file"
|
||||
|
||||
# ---- S7. worker .env 守门:占位未填 → 拒绝 ----
|
||||
cp "$PKG/worker.env.template" "$WDIR/.env"
|
||||
env HEL913_BASE=$BASE HEL913_AGENT_VENV=$STUB bash "$PKG/worker_ctl.sh" start >/dev/null 2>&1
|
||||
expect_rc 1 $? "worker_ctl refuses .env with unfilled placeholders (rc=1)"
|
||||
[ ! -f "$BASE/logs/worker.pid" ] && ok "placeholder refusal started nothing" || bad "placeholder refusal left pid file"
|
||||
|
||||
# ---- S8. worker .env 守门:解析失败 → 拒绝 ----
|
||||
printf 'CYBERGRIL_API_BASE=http://127.0.0.1:8360\nFOO=bar baz\n' > "$WDIR/.env"
|
||||
env HEL913_BASE=$BASE HEL913_AGENT_VENV=$STUB bash "$PKG/worker_ctl.sh" start >/dev/null 2>&1
|
||||
expect_rc 1 $? "worker_ctl refuses unparseable .env (rc=1)"
|
||||
[ ! -f "$BASE/logs/worker.pid" ] && ok "parse refusal started nothing" || bad "parse refusal left pid file"
|
||||
|
||||
# ---- S9. worker 启动失败收尾(注册不过 → 清自己、留日志) ----
|
||||
cat > "$WDIR/.env" <<'EOF'
|
||||
CYBERGRIL_API_BASE=http://127.0.0.1:8360
|
||||
CYBERGRIL_AGENT_NAME=cybergril-voice-agent
|
||||
LIVEKIT_URL=ws://127.0.0.1:7880
|
||||
LIVEKIT_API_KEY=filled
|
||||
LIVEKIT_API_SECRET=filled
|
||||
CYBERGRIL_WORKER_HEALTH_PORT=8082
|
||||
CYBERGRIL_VOICE_STATE=/tmp/x/voice_state.json
|
||||
CYBERGRIL_ASR_USAGE_LEDGER=/tmp/x/asr-usage.jsonl
|
||||
CYBERGRIL_ASR_WINDOW_ID=
|
||||
CYBERGRIL_ASR_WINDOW_MAX_AUDIO_SECONDS=0
|
||||
CYBERGRIL_ASR_MAX_CONNECT_RETRIES_PER_CALL=0
|
||||
EOF
|
||||
env HEL913_BASE=$BASE HEL913_AGENT_VENV=$STUB bash "$PKG/worker_ctl.sh" start >/dev/null 2>&1
|
||||
expect_rc 1 $? "worker_ctl failed start exits 1"
|
||||
[ ! -f "$BASE/logs/worker.pid" ] && ok "worker_ctl failed start removed pid file" || bad "worker_ctl failed start left pid file"
|
||||
[ -s "$BASE/logs/worker.log" ] && ok "worker_ctl failed start kept log" || bad "worker_ctl failed start lost log"
|
||||
sleep 1
|
||||
N=$(alive_marker "$STUB.*cybergril.voice.worker" | wc -l)
|
||||
[ "$N" = "0" ] && ok "worker_ctl failed start left no stub process" || bad "worker_ctl failed start left $N stub process(es)"
|
||||
|
||||
# ---- S10. worker 重复 start 拒绝 ----
|
||||
( cd "$WDIR" && nohup "$STUB" -m cybergril.voice.worker start > "$BASE/logs/worker.log" 2>&1 & echo $! > "$BASE/logs/worker.pid" )
|
||||
LIVEPID=$(cat "$BASE/logs/worker.pid")
|
||||
env HEL913_BASE=$BASE HEL913_AGENT_VENV=$STUB bash "$PKG/worker_ctl.sh" start >/dev/null 2>&1
|
||||
expect_rc 1 $? "worker_ctl duplicate start refused (rc=1)"
|
||||
kill "$LIVEPID" 2>/dev/null; wait 2>/dev/null
|
||||
rm -f "$BASE/logs/worker.pid"
|
||||
|
||||
# ---- S11. worker stop 的 PID 复用防护 ----
|
||||
sleep 600 & UNRELATED=$!
|
||||
echo "$UNRELATED" > "$BASE/logs/worker.pid"
|
||||
env HEL913_BASE=$BASE bash "$PKG/worker_ctl.sh" stop >/dev/null 2>&1; expect_rc 1 $? "worker_ctl stop refused reused pid (rc=1)"
|
||||
kill -0 "$UNRELATED" 2>/dev/null && ok "worker stop left unrelated process alive" || bad "worker stop killed unrelated process!"
|
||||
kill "$UNRELATED" 2>/dev/null; wait 2>/dev/null
|
||||
rm -f "$BASE/logs/worker.pid"
|
||||
|
||||
# ---- S12. 模板可解析性:arm 模板是合法 KEY=value(可被 source,默认全 0) ----
|
||||
if ( set -a; . "$PKG/voice-window-arm.template.env"; set +a
|
||||
[ "${HEL913_ASR_MAX_AUDIO_SECONDS:-x}" = "0" ] \
|
||||
&& [ -n "${HEL913_WINDOW_ID+x}" ] && [ -z "$HEL913_WINDOW_ID" ] \
|
||||
&& [ "${HEL913_TTS_SEGMENT_CAP:-x}" = "0" ] ) 2>/dev/null; then
|
||||
ok "voice-window-arm.template.env parses, defaults 0/unarmed"
|
||||
else
|
||||
bad "voice-window-arm.template.env unparseable or non-zero default"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "$PASS passed, $FAIL failed"
|
||||
[ "$FAIL" = "0" ]
|
||||
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env bash
|
||||
# HEL-913 运行包 · 共享 CosyVoice TTS 9880 窗口内临时恢复/停回模板(脱敏待批件)
|
||||
#
|
||||
# 只在获批语音窗口内使用;窗口结束必须 stop 停回(force_end.template.sh 会调
|
||||
# 本脚本 stop)。只按自己写的 pid 句柄停止,快照先行;9880 已被别人启动时
|
||||
# 不碰。改编自 HEL-910 已实测 tts_ctl.sh。子命令只认 start|stop|status|snapshot。
|
||||
#
|
||||
# 用法: [ENV=..] bash tts_ctl.template.sh start|stop|status|snapshot
|
||||
# 环境变量: HEL913_BASE / HEL913_TTS_VENV(/opt/voice-agent/cosyvoice/venv/bin/python)
|
||||
set -u
|
||||
BASE=${HEL913_BASE:-/opt/cybergril-hel913}
|
||||
CC=${HEL913_TTS_HOME:-/opt/voice-agent/cosyvoice}
|
||||
TTSVENV=${HEL913_TTS_VENV:-$CC/venv/bin/python}
|
||||
PIDF=$BASE/logs/tts9880.pid
|
||||
SNAP=$BASE/logs/tts9880-before.txt
|
||||
|
||||
usage() { echo "usage: [ENV=..] bash $0 start|stop|status|snapshot" >&2; exit 2; }
|
||||
|
||||
ours() {
|
||||
local p=$1 cmd cw
|
||||
case "$p" in ''|*[!0-9]*) return 1 ;; esac
|
||||
[ "$p" != "$$" ] || return 1
|
||||
kill -0 "$p" 2>/dev/null || return 1
|
||||
cmd=$(tr '\0' ' ' < "/proc/$p/cmdline" 2>/dev/null) || return 1
|
||||
cw=$(readlink "/proc/$p/cwd" 2>/dev/null) || return 1
|
||||
case "$cmd" in *"server.py"*) ;; *) return 1 ;; esac
|
||||
[ "$cw" = "$CC" ] || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
pidfile_pid() { [ -f "$PIDF" ] && cat "$PIDF" 2>/dev/null; }
|
||||
|
||||
case "${1:-}" in
|
||||
status)
|
||||
p=$(pidfile_pid)
|
||||
if [ -n "$p" ]; then ours "$p" && echo "running pid $p (ours)" || echo "pid $p not verified as ours"; else echo "not started by us"; fi
|
||||
curl -s --max-time 3 http://127.0.0.1:9880/health && echo " <- health" || echo "health not answering"
|
||||
exit 0 ;;
|
||||
snapshot)
|
||||
mkdir -p "$BASE/logs"
|
||||
{ echo "ts=$(date -u +%FT%TZ)"
|
||||
if curl -s --max-time 3 http://127.0.0.1:9880/health >/dev/null 2>&1; then echo "was=up"; else echo "was=down"; fi
|
||||
ss -ltn 2>/dev/null | grep ':9880 ' || echo "port9880=free"; } > "$SNAP"
|
||||
cat "$SNAP"; exit 0 ;;
|
||||
stop)
|
||||
p=$(pidfile_pid)
|
||||
if [ -z "$p" ]; then echo "not ours to stop (no pid file)"; exit 0; fi
|
||||
if kill -0 "$p" 2>/dev/null && ! ours "$p"; then
|
||||
echo "REFUSED: pid $p alive but not this tts (pid reuse?) — not killing; resolve $PIDF manually" >&2
|
||||
exit 1
|
||||
fi
|
||||
if ours "$p"; then kill "$p"; sleep 5; ours "$p" && kill -9 "$p"; fi
|
||||
rm -f "$PIDF"
|
||||
echo "tts stopped (pid $p)"
|
||||
exit 0 ;;
|
||||
esac
|
||||
|
||||
# start(仅 start 子命令落到这里)
|
||||
if curl -s --max-time 3 http://127.0.0.1:9880/health >/dev/null 2>&1; then
|
||||
echo "9880 already up — NOT ours, not touching"; exit 0
|
||||
fi
|
||||
if ss -ltn 2>/dev/null | grep -q ':9880 '; then
|
||||
echo "port 9880 occupied by non-healthy process — abort"; exit 1
|
||||
fi
|
||||
[ -x "$TTSVENV" ] || { echo "REFUSED: tts venv python not executable: $TTSVENV" >&2; exit 1; }
|
||||
cd "$CC" || exit 1
|
||||
nohup "$TTSVENV" server.py >> "$CC/tts.log" 2>&1 &
|
||||
echo $! > "$PIDF"
|
||||
echo "tts starting (pid $(cat "$PIDF")) — model load takes up to ~120s"
|
||||
for i in $(seq 1 60); do
|
||||
sleep 2
|
||||
if curl -s --max-time 3 http://127.0.0.1:9880/health 2>/dev/null | grep -q '"ok"[[:space:]]*:[[:space:]]*true'; then
|
||||
echo "OK: tts healthy after ~$((i*2))s"
|
||||
wc -c < "$CC/tts.log" > "$BASE/logs/tts-log-start-byte" # TTS 段数计数的窗口起点
|
||||
exit 0
|
||||
fi
|
||||
kill -0 "$(cat "$PIDF")" 2>/dev/null || { echo "FAIL: tts process died"; tail -10 "$CC/tts.log"; exit 1; }
|
||||
done
|
||||
echo "FAIL: tts not healthy in 120s"; tail -10 "$CC/tts.log"; exit 1
|
||||
@@ -0,0 +1,12 @@
|
||||
# HEL-913 · 语音窗口一次性布防模板(脱敏;默认全 0/未布防,随包不生效)
|
||||
#
|
||||
# 获批语音窗口的负责人在窗口启动时显式填写并在启动 worker 前写入
|
||||
# <实例>/worker/.env(ASR 三项)与本文件(窗口参数)。唯一接线见
|
||||
# deploy/hel913-unified/README.md §5;建议值口径见
|
||||
# docs/hel913-capability-and-enablement.md §2 B。
|
||||
# 已实测同形工具(HEL-910 窗口):docs/rework/hel910/tools/asr-arm.env。
|
||||
HEL913_WINDOW_ID= # 例 hel913-20261106-a;空=未布防=拒绝一切 ASR
|
||||
HEL913_ASR_MAX_AUDIO_SECONDS=0 # 全窗口实际送入 ASR 音频硬闸(秒)
|
||||
HEL913_ASR_MAX_RETRIES_PER_CALL=0 # 每通连接重试硬闸(失败后的再建连)
|
||||
HEL913_TTS_SEGMENT_CAP=0 # TTS 段数上限(监控口径;到顶即手动 force_end)
|
||||
HEL913_WINDOW_DEADLINE_EPOCH= # date -d '<第3日> 24:00' +%s;到点 force_end
|
||||
@@ -1,11 +1,15 @@
|
||||
# HEL-913 统一体验运行包 · voice 配置模板(脱敏)
|
||||
#
|
||||
# 用法:复制到 <实例>/etc/voice.yaml。真实值属于服务器本地(不入仓库):
|
||||
# livekit 指向 .12 本机 LiveKit(内部明文 7880;浏览器侧若走独立 TLS 桥,
|
||||
# 由部署时的 wss 桥地址替换 livekit_url,桥属可选件);TTS/面板地址在
|
||||
# 语音窗口获批启动后填本机 9880/8090。registry/worker_state 落在实例数据
|
||||
# 目录内,与产品库同空间,随实例备份。
|
||||
livekit_url: <ws://127.0.0.1:7880 或获批 wss 桥地址>
|
||||
# 用法:复制到 <实例>/etc/voice.yaml,把 <...> 占位替换成服务器本地真实值。
|
||||
# livekit_url 是 POST /api/voice/session 发给**浏览器**的接入地址:统一实例
|
||||
# 页面走 HTTPS(8361),HTTPS 页面连 ws:// 明文会被混合内容策略阻断,因此
|
||||
# 语音可用的前提是 wss TLS 桥(deploy/voice/wss_bridge.example.py 在新端口
|
||||
# 终结 TLS、回环转发 7880,与 8361 同一张自签证书)——livekit_url 必须填
|
||||
# 桥的 wss:// 地址,不是可选件(桥的启停见 README §5)。服务器内部
|
||||
# (开房/删房/worker 注册)仍走 livekit_internal 的本机明文 7880。
|
||||
# TTS/面板地址在语音窗口获批启动后指向本机 9880/8090;registry/worker_state
|
||||
# 落实例数据目录,与产品库同空间,随实例备份。
|
||||
livekit_url: wss://192.168.200.12:8363
|
||||
livekit_internal: http://127.0.0.1:7880
|
||||
api_key: <LiveKit api key,服务器本地>
|
||||
api_secret: <LiveKit api secret,服务器本地>
|
||||
@@ -13,7 +17,7 @@ agent_name: cybergril-voice-agent
|
||||
tts_health_url: http://127.0.0.1:9880/health
|
||||
panel_url: https://127.0.0.1:8090
|
||||
tts_url: http://127.0.0.1:9880
|
||||
registry_file: <实例数据目录>/voices.json
|
||||
worker_state_file: <实例数据目录>/voice_state_cybergril.json
|
||||
registry_file: /opt/cybergril-hel913/data/voices.json
|
||||
worker_state_file: /opt/cybergril-hel913/data/voice_state_cybergril.json
|
||||
token_ttl_seconds: 300
|
||||
session_ttl_seconds: 900
|
||||
|
||||
@@ -1,12 +1,26 @@
|
||||
# HEL-913 统一体验运行包 · 语音 worker 环境模板(脱敏)
|
||||
# 用法:复制到 <实例>/worker/.env。真实 LiveKit 凭据属于服务器本地。
|
||||
#
|
||||
# 用法:复制到 <实例>/worker/.env,把所有 <...> 占位替换成服务器本地真实值。
|
||||
# worker_ctl.sh 启动前会拒绝:仍含 <...> 占位的文件、解析失败的文件、缺文件。
|
||||
# 运行解释器是 agent venv(livekit-agents 1.8.8),不是产品 .venv311。
|
||||
CYBERGRIL_API_BASE=http://127.0.0.1:<API HTTP 端口>
|
||||
CYBERGRIL_API_BASE=http://127.0.0.1:8360
|
||||
CYBERGRIL_AGENT_NAME=cybergril-voice-agent
|
||||
LIVEKIT_URL=ws://127.0.0.1:7880
|
||||
LIVEKIT_API_KEY=<LiveKit api key,服务器本地>
|
||||
LIVEKIT_API_SECRET=<LiveKit api secret,服务器本地>
|
||||
CYBERGRIL_WORKER_HEALTH_PORT=<worker 健康端口,如 8082,须未占用>
|
||||
CYBERGRIL_VOICE_STATE=<实例数据目录>/voice_state_cybergril.json
|
||||
# ASR 用量账本独立于产品库,落在实例数据目录:
|
||||
CYBERGRIL_ASR_USAGE_LEDGER=<实例数据目录>/asr-usage.jsonl
|
||||
CYBERGRIL_WORKER_HEALTH_PORT=8082
|
||||
CYBERGRIL_VOICE_STATE=/opt/cybergril-hel913/data/voice_state_cybergril.json
|
||||
# ASR 用量账本独立于产品库,落在实例数据目录(逐通历史不随删房消失):
|
||||
CYBERGRIL_ASR_USAGE_LEDGER=/opt/cybergril-hel913/data/asr-usage.jsonl
|
||||
|
||||
# —— ASR 一次性窗口闸(HEL-906;本段是布防接线,默认未布防 = 真实 cap=0)——
|
||||
# 三项保持空/0 时,worker 拒绝一切真实 ASR 新连接与新音频(fail-closed,
|
||||
# 拒绝本身落账,src/cybergril/voice/asr_usage.py)。只有获批语音窗口的
|
||||
# 负责人在窗口启动时显式改这里并重启 worker(接线与建议值见 README §5
|
||||
# 与 docs/hel913-capability-and-enablement.md §2 B):
|
||||
# CYBERGRIL_ASR_WINDOW_ID=hel913-<日期>-a # 新窗口 id;空=未布防
|
||||
# CYBERGRIL_ASR_WINDOW_MAX_AUDIO_SECONDS=1800 # 3 通×10 分钟=30 分钟硬闸
|
||||
# CYBERGRIL_ASR_MAX_CONNECT_RETRIES_PER_CALL=2 # 每通连接重试上限
|
||||
CYBERGRIL_ASR_WINDOW_ID=
|
||||
CYBERGRIL_ASR_WINDOW_MAX_AUDIO_SECONDS=0
|
||||
CYBERGRIL_ASR_MAX_CONNECT_RETRIES_PER_CALL=0
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
# HEL-913 统一体验运行包 · 专属语音 worker 启停(只按 PID 句柄停止)
|
||||
# HEL-913 统一体验运行包 · 专属语音 worker 启停
|
||||
#
|
||||
# 运行解释器是 agent venv(livekit-agents 1.8.8),产品代码经 PYTHONPATH 注入。
|
||||
# worker 只连接本实例 API 与本机 LiveKit;停止只杀自己写的 PID,不匹配进程名。
|
||||
# worker 只连接本实例 API 与本机 LiveKit。本脚本只做本实例常规启停安全:
|
||||
# - 子命令只认 start|stop|status,其他一律拒绝退出 2(不会静默当 start);
|
||||
# - start 前核对 pid 句柄与 worker/.env(缺文件/含未填 <...> 占位/解析失败
|
||||
# 一律拒绝),重复 start 拒绝,句柄 pid 复用拒绝;
|
||||
# - stop/失败收尾只杀经身份核验的进程(cmdline 含 cybergril.voice.worker
|
||||
# 且 cwd 是本实例 worker 目录),绝不按进程名扫杀;
|
||||
# - start 注册检查不过 → 清掉自己刚起的进程、保留日志、退出 1。
|
||||
#
|
||||
# 用法: [ENV=..] bash deploy/hel913-unified/worker_ctl.sh start|stop|status
|
||||
# 环境变量:
|
||||
@@ -13,36 +19,118 @@ set -u
|
||||
BASE=${HEL913_BASE:-/opt/cybergril-hel913}
|
||||
VENV=${HEL913_AGENT_VENV:-/opt/voice-agent/agent/venv/bin/python}
|
||||
HEALTH=${HEL913_WORKER_HEALTH:-8082}
|
||||
WDIR=$BASE/worker
|
||||
ENVF=$WDIR/.env
|
||||
LOG=$BASE/logs/worker.log
|
||||
PIDF=$BASE/logs/worker.pid
|
||||
MARKER="cybergril.voice.worker"
|
||||
|
||||
usage() { echo "usage: [ENV=..] bash $0 start|stop|status" >&2; exit 2; }
|
||||
|
||||
ours() {
|
||||
local p=$1 cmd cw
|
||||
case "$p" in ''|*[!0-9]*) return 1 ;; esac
|
||||
[ "$p" != "$$" ] || return 1
|
||||
kill -0 "$p" 2>/dev/null || return 1
|
||||
cmd=$(tr '\0' ' ' < "/proc/$p/cmdline" 2>/dev/null) || return 1
|
||||
cw=$(readlink "/proc/$p/cwd" 2>/dev/null) || return 1
|
||||
case "$cmd" in *"$MARKER"*) ;; *) return 1 ;; esac
|
||||
[ "$cw" = "$WDIR" ] || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
pidfile_pid() { [ -f "$PIDF" ] && cat "$PIDF" 2>/dev/null; }
|
||||
|
||||
stop() {
|
||||
if [ -f "$PIDF" ]; then
|
||||
P=$(cat "$PIDF")
|
||||
if [ "$P" != "$$" ] && kill -0 "$P" 2>/dev/null; then kill "$P"; sleep 3; fi
|
||||
if [ "$P" != "$$" ] && kill -0 "$P" 2>/dev/null; then kill -9 "$P"; fi
|
||||
rm -f "$PIDF"
|
||||
echo "worker stopped (pid $P)"
|
||||
else
|
||||
local p
|
||||
p=$(pidfile_pid)
|
||||
if [ -z "$p" ]; then
|
||||
echo "no pid file; nothing stopped"
|
||||
return 0
|
||||
fi
|
||||
if kill -0 "$p" 2>/dev/null && ! ours "$p"; then
|
||||
echo "REFUSED: pid $p is alive but is NOT this worker (pid reuse?) — not killing; resolve $PIDF manually" >&2
|
||||
return 1
|
||||
fi
|
||||
if ours "$p"; then
|
||||
kill "$p"
|
||||
sleep 3
|
||||
if ours "$p"; then kill -9 "$p"; sleep 1; fi
|
||||
fi
|
||||
rm -f "$PIDF"
|
||||
echo "worker stopped (pid $p)"
|
||||
return 0
|
||||
}
|
||||
|
||||
start() {
|
||||
local p bad
|
||||
p=$(pidfile_pid)
|
||||
if [ -n "$p" ] && kill -0 "$p" 2>/dev/null; then
|
||||
if ours "$p"; then
|
||||
echo "REFUSED: worker already running (pid $p) — stop first" >&2
|
||||
else
|
||||
echo "REFUSED: pid file has live pid $p that is not this worker (pid reuse?) — resolve $PIDF manually" >&2
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
rm -f "$PIDF"
|
||||
[ -d "$WDIR" ] || { echo "REFUSED: worker dir missing: $WDIR" >&2; exit 1; }
|
||||
[ -f "$ENVF" ] || { echo "REFUSED: $ENVF missing (copy worker.env.template and fill it)" >&2; exit 1; }
|
||||
[ -x "$VENV" ] || { echo "REFUSED: agent venv python not executable: $VENV" >&2; exit 1; }
|
||||
# 占位符守门:模板 <...> 未替换一律拒绝(不让占位串进进程环境)
|
||||
bad=$(grep -nE '^[A-Za-z_][A-Za-z0-9_]*=.*<' "$ENVF" || true)
|
||||
if [ -n "$bad" ]; then
|
||||
echo "REFUSED: $ENVF still has unfilled <...> placeholders:" >&2
|
||||
echo "$bad" >&2
|
||||
exit 1
|
||||
fi
|
||||
# 解析守门:.env 必须能作为 KEY=value 被 source(坏引号/裸空格拒绝)
|
||||
if ! (set -a; . "$ENVF"; set +a) 2>/dev/null; then
|
||||
echo "REFUSED: $ENVF does not parse as KEY=value lines" >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$BASE/logs"
|
||||
cd "$WDIR" || exit 1
|
||||
set -a
|
||||
. "$ENVF"
|
||||
set +a
|
||||
PYTHONPATH="$BASE/current/src" nohup "$VENV" -m cybergril.voice.worker start > "$LOG" 2>&1 &
|
||||
p=$!
|
||||
echo "$p" > "$PIDF"
|
||||
echo "worker starting (pid $p)"
|
||||
sleep 18
|
||||
if grep -m1 "registered worker" "$LOG" >/dev/null; then
|
||||
echo "OK: worker registered"
|
||||
return 0
|
||||
fi
|
||||
echo "FAIL: worker did not register — full log kept at $LOG; tail:" >&2
|
||||
tail -8 "$LOG" >&2
|
||||
if ours "$p"; then
|
||||
kill "$p"; sleep 2
|
||||
ours "$p" && kill -9 "$p"
|
||||
fi
|
||||
rm -f "$PIDF"
|
||||
echo "cleaned up failed start (log kept: $LOG)" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
status() {
|
||||
local p
|
||||
p=$(pidfile_pid)
|
||||
if [ -n "$p" ]; then
|
||||
if ours "$p"; then echo "running pid $p (identity verified)"
|
||||
elif kill -0 "$p" 2>/dev/null; then echo "pid $p alive but NOT ours (stale pid file?)"
|
||||
else echo "pid $p not alive (stale pid file)"; fi
|
||||
else
|
||||
echo "no pid file"
|
||||
fi
|
||||
curl -s --max-time 3 "http://127.0.0.1:$HEALTH/" >/dev/null && echo "health ok" \
|
||||
|| echo "health port not answering"
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
stop) stop; exit 0 ;;
|
||||
status)
|
||||
if [ -f "$PIDF" ]; then P=$(cat "$PIDF"); kill -0 "$P" 2>/dev/null && echo "running pid $P" || echo "pid $P not alive"; fi
|
||||
curl -s --max-time 3 "http://127.0.0.1:$HEALTH/" >/dev/null && echo "health ok" || echo "health port not answering"
|
||||
exit 0 ;;
|
||||
start) start ;;
|
||||
stop) stop ;;
|
||||
status) status ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
|
||||
cd "$BASE/worker"
|
||||
set -a
|
||||
source "$BASE/worker/.env"
|
||||
set +a
|
||||
PYTHONPATH="$BASE/current/src" nohup "$VENV" -m cybergril.voice.worker start > "$LOG" 2>&1 &
|
||||
echo $! > "$PIDF"
|
||||
echo "worker starting (pid $(cat "$PIDF"))"
|
||||
sleep 18
|
||||
grep -m1 "registered worker" "$LOG" >/dev/null && echo "OK: worker registered" \
|
||||
|| { echo "FAIL:"; tail -8 "$LOG"; exit 1; }
|
||||
|
||||
Reference in New Issue
Block a user