safesight-control/docs/deployment.md
tian 24b9400767 feat: 离线部署包一体化,启动自动导入种子数据,人脸库构建流程修复
- package.sh: 打包包含 configs 种子数据、tools 构建工具、deps 离线依赖、scripts 辅助脚本
- ImportSeedAssets: 首次启动检测空库自动导入 templates/profiles/overlays
- face_gallery.html: 添加构建人脸库按钮
- device.html: 无标准配置时显示设备实际模型/资源,无人脸库配置时隐藏按钮
- register-face-gallery.py: 手动注册已构建人脸库到 standard_resources
- deployment.md: 更新部署流程反映新包结构
- .gitignore: 排除 *.tar.gz 构建产物
2026-07-23 17:57:47 +08:00

2.4 KiB
Raw Blame History

SafeSight Control 部署指南

打包

在开发机上(需 Git Bash 或 Linux/WSL

cd safesight-control
bash scripts/package.sh

生成 safesight-control-*.tar.gz,包含:

  • ARM64 + AMD64 二进制
  • service 文件、配置示例
  • 种子配置数据configs/templates、profiles、overlays
  • 人脸库构建工具tools/Python 脚本 + ONNX 模型)
  • 离线 Python 依赖deps/onnxruntime wheel
  • 辅助脚本scripts/import-assets、register-face-gallery

部署ARM64

# 传到设备
scp safesight-control-*.tar.gz user@server:/tmp/

# 解压
cd /tmp && tar -xzf safesight-control-*.tar.gz
cd safesight-control-*

# 安装
sudo mkdir -p /opt/safesightd/{bin,config,data}
sudo cp safesightd-linux-arm64 /opt/safesightd/bin/safesightd
sudo chmod +x /opt/safesightd/bin/safesightd
sudo cp safesightd.json.example /opt/safesightd/config/safesightd.json
sudo cp -r configs /opt/safesightd/
sudo cp -r tools /opt/safesightd/
sudo cp -r scripts /opt/safesightd/

# 安装服务
sudo cp safesightd.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now safesightd

# 首次启动自动导入种子数据,无需手动操作

AMD64 部署同上,二进制改为 safesightd-linux-amd64


配置

编辑 /opt/safesightd/config/safesightd.json

{
  "listen": "0.0.0.0:18080",
  "discovery_port": 35688,
  "discovery_timeout_ms": 1200,
  "offline_after_ms": 10000,
  "agent_token": "4fe2d69fda23d0d5d04a1486d4920e68",
  "concurrency": 5,
  "data_dir": "/opt/safesightd/data",
  "db_path": "/opt/safesightd/data/app.db",
  "log_dir": "/opt/safesightd/data/logs",
  "alarm_retention_days": 30
}

人脸库构建(离线环境)

# 1. 离线安装 Python 依赖(仅首次)
sudo pip3 install /opt/safesightd/deps/*.whl

# 2. 通过 Web UI 导入照片后,触发构建
curl -X POST http://localhost:18080/face-gallery/build

# 3. 如从外部传入已构建的 face_gallery.db
sudo mkdir -p /opt/safesightd/resources/standard_resources/face_gallery
sudo cp face_gallery.db /opt/safesightd/resources/standard_resources/face_gallery/
sudo python3 /opt/safesightd/scripts/register-face-gallery.py
sudo systemctl restart safesightd

验证

systemctl status safesightd
curl http://localhost:18080/api/devices

浏览器打开 http://<IP>:18080