配置说明
juhe-sync.json 配置文件详细说明
配置文件路径
默认配置文件路径:./juhe-sync.json
可通过 --config 参数指定其他路径:
bash
./juhe-sync run --config /path/to/custom-config.json完整配置示例
json
{
"api_url": "https://chat-api.juhebot.com",
"app_key": "your_app_key",
"app_secret": "your_app_secret",
"guids": ["guid_enterprise_1", "guid_wx_2"],
"guid_types": {
"guid_enterprise_1": "enterprise",
"guid_wx_2": "wx"
},
"port": 8070,
"db_path": "./juhe-sync.db",
"sync_interval": 300
}参数说明
| 字段名 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
api_url | string | 是 | - | SAAS API 地址 |
app_key | string | 是 | - | 应用 Key |
app_secret | string | 是 | - | 应用 Secret |
guids | string[] | 是 | - | 需要同步的设备 GUID 列表 |
guid_types | object | 否 | GUID 类型映射,可选值:enterprise/wx | |
port | number | 否 | 8070 | HTTP 服务端口 |
db_path | string | 否 | ./juhe-sync.db | SQLite 数据库文件路径 |
sync_interval | number | 否 | 300 | 增量同步间隔(秒) |
环境变量配置
支持通过环境变量覆盖配置文件中的部分设置:
| 环境变量 | 对应字段 | 说明 |
|---|---|---|
JUHE_SYNC_API_URL | api_url | SAAS API 地址 |
JUHE_SYNC_APP_KEY | app_key | 应用 Key |
JUHE_SYNC_APP_SECRET | app_secret | 应用 Secret |
JUHE_SYNC_PORT | port | HTTP 服务端口 |
JUHE_SYNC_DB_PATH | db_path | 数据库文件路径 |
使用环境变量
bash
# 设置环境变量
export JUHE_SYNC_API_URL="https://chat-api.juhebot.com"
export JUHE_SYNC_APP_KEY="your_key"
export JUHE_SYNC_APP_SECRET="your_secret"
export JUHE_SYNC_PORT="8080"
# 启动服务
./juhe-sync run --config juhe-sync.jsonGUID 类型映射
当配置多个 GUID 时,建议明确指定每个 GUID 的类型。 这对于正确处理企微和个微的不同协议非常重要。
类型值
enterprise:企业微信wx:个人微信
示例
json
{
"guids": ["ent_001", "wx_001"],
"guid_types": {
"ent_001": "enterprise",
"wx_001": "wx"
}
}数据库配置
SQLite 数据库
juhe-sync 使用 SQLite 存储联系人、消息等数据。 数据库文件会在首次启动时自动创建。
数据表结构
contacts:联系人信息messages:消息记录rooms:群聊信息sync_status:同步状态
同步间隔配置
sync_interval 控制增量同步的频率(秒)。 较小的值可以更快获取新数据,但会增加 API 调用频率。
- 推荐值:300 秒(5 分钟)
- 实时性要求高:60-120 秒
- 节省资源:600 秒(10 分钟)