配置文件说明
ThingsGatewayRuntime 采用分层配置加载机制,配置文件位于 GatewayApp/ 目录下。
配置加载机制
系统启动时自动合并 Configuration/ 目录下所有 .json 文件的内容到运行时配置中。
配置文件清单
| 文件 | 说明 |
|---|---|
appsettings.json | 主配置,定义扫描目录 |
Configuration/WebApiOptions.json | Web API 服务端口配置 |
Configuration/LoggerOptions.json | 日志配置 |
Configuration/Database.json | 数据库连接配置 |
Configuration/JWTOptions.json | JWT 认证配置 |
Configuration/ChannelThread.json | 通道线程与容量配置 |
Configuration/IdGeneratorOptions.json | 雪花 ID 生成器配置 |
WebApiOptions 配置
| 配置项 | 说明 | 默认值 |
|---|---|---|
| Urls | 监听地址,格式为 http://*:{端口} | http://*:6100 |
提示
修改端口后需重启网关应用才能生效。确保新端口未被其他程序占用。
LoggerOptions 配置
| 配置项 | 说明 |
|---|---|
| LogLevel | 日志级别 |
| WriteToFile | 是否写入文件 |
| FilePath | 日志文件路径 |
Database 配置
| 配置项 | 说明 |
|---|---|
| ConnectionString | 数据库连接字符串 |
| DbType | 数据库类型 |
JWTOptions 配置
| 配置项 | 说明 |
|---|---|
| SecretKey | JWT 密钥 |
| Issuer | 签发者 |
| Audience | 受众 |
| ExpirationMinutes | 过期时间(分钟) |
ChannelThread 配置
| 配置项 | 说明 | 默认值 |
|---|---|---|
| CheckInterval | 检查间隔(毫秒),定期检查通道和设备状态 | 1800000(30分钟) |
| MaxChannelCount | 允许的最大通道数量 | 10000 |
| MaxDeviceCount | 允许的最大设备数量 | 10000 |
| MaxVariableCount | 允许的最大变量数量 | 10000000 |
性能调优
- MaxChannelCount/MaxDeviceCount/MaxVariableCount 用于限制系统资源使用,防止配置过多导致性能下降
- 这些限制与授权限制独立,取两者中较小的值作为实际限制
- CheckInterval 建议保持默认值,过短的检查间隔会增加系统开销