# Linux 部署步骤（给 mohe 参考）

## 1. hermes-gateway@.service

```bash
# 复制模板
sudo cp /path/to/deploy/linux/hermes-gateway@.service /etc/systemd/system/
sudo systemctl daemon-reload

# 启用默认 gateway（8642端口）
sudo systemctl enable --now hermes-gateway@default

# 验证
systemctl status hermes-gateway@default
```

## 2. state.db 清理

```bash
cd ~/.hermes/profiles/main

# 方案A：CLI 清理（推荐）
hermes session prune --older-than 30d

# 方案B：手动清理
sqlite3 state.db "DELETE FROM sessions WHERE time_created < strftime('%s','now','-30 days'); VACUUM;"
```

## 3. Provider key 迁移

```yaml
# config.yaml 中用环境变量替换
providers:
  volcengine:
    api_key: ${VOLCENGINE_KEY}    # 从 .env 读取
  ocg-new:
    api_key: ${OCG_NEW_KEY}
  ocg-old:
    api_key: ${OCG_OLD_KEY}
```

```bash
# .env 文件
echo "VOLCENGINE_KEY=xxx" >> ~/.hermes/.env
echo "OCG_NEW_KEY=xxx" >> ~/.hermes/.env
echo "OCG_OLD_KEY=xxx" >> ~/.hermes/.env
```
