跳转到主要内容

配置说明

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_urlstring-SAAS API 地址
app_keystring-应用 Key
app_secretstring-应用 Secret
guidsstring[]-需要同步的设备 GUID 列表
guid_typesobjectGUID 类型映射,可选值:enterprise/wx
portnumber8070HTTP 服务端口
db_pathstring./juhe-sync.dbSQLite 数据库文件路径
sync_intervalnumber300增量同步间隔(秒)

环境变量配置

支持通过环境变量覆盖配置文件中的部分设置:

环境变量对应字段说明
JUHE_SYNC_API_URLapi_urlSAAS API 地址
JUHE_SYNC_APP_KEYapp_key应用 Key
JUHE_SYNC_APP_SECRETapp_secret应用 Secret
JUHE_SYNC_PORTportHTTP 服务端口
JUHE_SYNC_DB_PATHdb_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.json

GUID 类型映射

当配置多个 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 分钟)