feat(recording): consolidate recording pipeline on server B
This commit is contained in:
@@ -2,6 +2,21 @@
|
||||
|
||||
> 任务:S24 - 录音搬运与播放
|
||||
> 完成时间:2026-06-21 20:20 +08:00
|
||||
> 当前模式:S56 - Server B 本机录音闭环(2026-08-27)
|
||||
|
||||
## 0. 当前生产架构(S56)
|
||||
|
||||
录音不再经过 B 到 A 的专用 SSH。Server B 上的 RTPEngine Recording Daemon 先写入
|
||||
`/dev/shm/voip_rec/incoming`,本机 finalizer 将稳定文件原子改名为
|
||||
`/dev/shm/voip_rec/ready/**/*.ready`,Recording Worker 再复制、校验并持久化到
|
||||
`/data/recordings`,最后写入数据库并删除本机 `.ready` 源文件。
|
||||
|
||||
```text
|
||||
B RTPEngine -> B incoming -> B finalizer -> B ready
|
||||
-> B Recording Worker -> B /data/recordings + MySQL
|
||||
```
|
||||
|
||||
旧的 B -> A SSH 配置仅作为短期回滚材料保留,不参与当前服务。S24 以下章节保留为历史实施记录。
|
||||
|
||||
## 1. 目标
|
||||
|
||||
@@ -26,8 +41,23 @@ S24 完成录音闭环的最小能力:
|
||||
|
||||
## 3. Worker 环境变量
|
||||
|
||||
S56 当前生产配置:
|
||||
|
||||
```text
|
||||
DATABASE_URL
|
||||
RECORDING_SOURCE_MODE=local
|
||||
RECORDING_LOCAL_READY_DIR=/dev/shm/voip_rec/ready
|
||||
RECORDING_LOCAL_ROOT=/data/recordings
|
||||
RECORDING_SCAN_INTERVAL_MS=10000
|
||||
RECORDING_MAX_FILES_PER_SCAN=50
|
||||
RECORDING_DELETE_SOURCE_AFTER_COPY=true
|
||||
```
|
||||
|
||||
`RECORDING_SOURCE_MODE=ssh` 仍受代码支持,以下变量只用于回滚到旧架构:
|
||||
|
||||
```text
|
||||
DATABASE_URL
|
||||
RECORDING_SOURCE_MODE=ssh
|
||||
RECORDING_REMOTE_HOST=lisglosips-a
|
||||
RECORDING_SSH_CONFIG=/etc/lisglosips/recording/ssh_config
|
||||
RECORDING_REMOTE_READY_DIR=/dev/shm/voip_rec/ready
|
||||
@@ -37,12 +67,16 @@ RECORDING_MAX_FILES_PER_SCAN=50
|
||||
RECORDING_DELETE_SOURCE_AFTER_COPY=true
|
||||
```
|
||||
|
||||
本地开发可使用 `.codex-private/ssh/config`;生产或 B 端 systemd 应使用 `/etc/lisglosips/recording/` 下的受控 key 和 known_hosts。
|
||||
SSH 模式本地开发可使用 `.codex-private/ssh/config`;生产回滚时才使用 `/etc/lisglosips/recording/` 下的受控 key 和 known_hosts。
|
||||
|
||||
## 4. 服务器变更
|
||||
|
||||
### Server B
|
||||
|
||||
- S56 新增 `lisglosips-recording-finalize.timer`,每 5 秒检查本机稳定录音文件。
|
||||
- Recording Worker 以 `lisglo-recorder` 身份运行,通过 `SupplementaryGroups=rtpengine` 访问 ready 目录。
|
||||
- systemd 只开放 `/dev/shm/voip_rec/ready` 与 `/data/recordings` 所需写权限。
|
||||
- Worker 使用 `RECORDING_SOURCE_MODE=local`,运行期不再启动 `ssh` 子进程。
|
||||
- 新增 `/etc/lisglosips/recording/a_pull_ed25519`,权限 `0640 root:lisglosips`。
|
||||
- 新增 `/etc/lisglosips/recording/known_hosts`。
|
||||
- 录音持久化目录仍为 `/data/recordings`,由 `lisglo-recorder:lisglosips` 管理。
|
||||
@@ -109,7 +143,7 @@ location /_recordings/ {
|
||||
|
||||
## 7. 当前限制
|
||||
|
||||
B 当前 `/opt/lisglosips/current` 仍是 S05 placeholder release,未切换到完整 monorepo API/Worker release。因此 S24 本次完成代码、构建、服务器私网拉取链路和 Nginx 内部播放保护验证;正式 `lisglosips@recording-worker.service` 随完整应用 release 发布时启用。
|
||||
S24 记载的 placeholder 限制已经失效;B 已运行完整 monorepo API/Worker release。S56 不迁移 A 的历史录音,也不自动删除旧 SSH key;旧凭据待本地闭环稳定运行并完成真实录音验收后再单独清理。
|
||||
|
||||
## 8. 回滚
|
||||
|
||||
@@ -125,8 +159,11 @@ sudo chmod 0750 /dev/shm/voip_rec/ready
|
||||
Server B:
|
||||
|
||||
```bash
|
||||
sudo rm -rf /etc/lisglosips/recording
|
||||
sudo rm -rf /data/recordings/s24-smoke
|
||||
sudo systemctl disable --now lisglosips-recording-finalize.timer
|
||||
sudo cp /var/backups/lisglosips-s56/<timestamp>/recording-worker.env /etc/lisglosips/recording-worker.env
|
||||
sudo cp /var/backups/lisglosips-s56/<timestamp>/10-s28-recording.conf /etc/systemd/system/lisglosips@recording-worker.service.d/10-s28-recording.conf
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl restart lisglosips@recording-worker
|
||||
```
|
||||
|
||||
代码回滚:
|
||||
|
||||
Reference in New Issue
Block a user