系统配置文件config.json的说明 - grantgonggithub/SuperGMS GitHub Wiki
SuperGMS的配置文件分为两种:
一种是项目中的微服务的配置文件,这个配置文件其实是个指向配置中心的指向配置,本身没有配置内容,它指向了第二种配置文件的地址,另外一种是真正包含配置内容的文件,可以是接口地址,也可以是可以访问的静态文件,下面具体说明:
一、第一种配置文件:
以HttpProxy项目为例,发布后在publish目录下会生成三配置文件:
1、config.json 开发环境的配置文件内容如下:
{
"ServerConfig": {
"ConfigCenter": {
"ConfigType": 3,
"Ip": "http://localhost/config.json" // 本机IIS调试用,这个配置文件放在IIS根目录下
}
} }
2、config.test.json 测试环境的配置文件内容如下:
"ServerConfig": {
"ConfigCenter": {
"ConfigType": 3,
"Ip": "http://192.168.100.201/config/config.test.json" // 测试环境配置文件的地址
}
}
}
3、config.pre.json 预发布环境配置
{
"ServerConfig": {
"ConfigCenter": {
"ConfigType": 3,
"Ip": "http://a.supergms.com/config/config.pre.json" // 指向预发布环境的配置文件
}
}
}
二、第二种配置文件
真正的配置文件是配置中心的文件,这个文件可以是接口返回的json内容,也可以是一个放在一个站点下直接可以访问的静态文件,内容如下所示:
{
"ServerConfig": {
"RpcService": {
"Pool": 0,
"Ip": "192.168.7.*", // 对于多网卡的机器,配置了一个特定的网卡段
"Port": 0,
"PortList": { // 各个服务监听的端口
"HttpProxy": 20001,
"A_Service": 20002,
"B_Service": 20003,
"C_Service": 20004,
"D_Service": 20005
},
"ServerType": 2,
"AssemblyPath": null,
"TimeOut": 0,
"Enable": true
},
"ConfigCenter": {
"ConfigType": 1,
"Ip": "192.168.100.201:2181",
"SessionTimeout": 5000
}
},
"DataBase": { // 数据库配置信息
"RefFile": "true", // 是否是指向文件
"DbFile": "database.config", //数据库配置文件地址,当前运行目录下的config目录中的database.config 也可以是一个完整的http地址
"SqlFile": "sqlmap.config" // sql脚本文件,路径结构同DbFile
},
"NLog": { // Nlog配置 "autoReload": false, "throwConfigExceptions": true, "internalLogLevel": "info", "internalLogFile": "${basedir}/txtLog/internal-nlog.txt", "extensions": [ { "assembly": "NLog.Extensions.Logging" } ], "default-wrapper": { "type": "AsyncWrapper", "overflowAction": "Block" }, "targets": { "all-file": { "type": "File", "layout": "${longdate}\r${uppercase:${level}}\r\n${event-properties:item=EventId_Name:whenEmpty=}\r\n${logger}|${callsite}\r\n${message}\r\n ${exception:format=tostring}\r\n-------------------------------------------------------------------\r\n", "fileName": "${basedir}/txtLog/${shortdate}/${shortdate}.txt", "archiveFileName": "${basedir}/txtLog/${shortdate}/{#}.txt", "archiveAboveSize": "31457280", "archiveNumbering": "DateAndSequence", "archiveDateFormat": "yyyyMMddHH", "encoding": "UTF-8" }, "own-console": { "type": "LimitingWrapper", "interval": "00:00:01", "messageLimit": 100, "target": { "type": "ColoredConsole", "layout": "${longdate}\r${event-properties:item=EventId_Id:whenEmpty=}\r\n${uppercase:${level}}\r\n${logger}\r\n${message}\r\n${exception:format=tostring}${callsite}\r\n-------------------------------------------------------------------\r\n", "rowHighlightingRules": [ { "condition": "level == LogLevel.Error", "foregroundColor": "Red" }, { "condition": "level == LogLevel.Fatal", "foregroundColor": "Red", "backgroundColor": "White" } ] } } }, "rules": [ { "logger": "*", "minLevel": "Debug", "writeTo": "all-file,own-console" } ] },
"ConstKeyValue": { // 可以配置类似key-value的值,在程序中直接获取
"Items": [
{
"Key": "MaxHttpBody",
"Value": "104857600"
},
{
"Key": "TrackSql",
"Value": "true"
},
{
"Key": "ReceiptUrl",
"Value": "D:/Images/"
}
]
},
"RabbitMQ": { // RabbitMQ配置
"Host": [
{
"Name": "Default",
"Ip": "192.168.100.78",
"Port": 5672,
"UserName": "tttttt",
"PassWord": "xxxxx",
"NoAckMsgCount": 5
}
]
},
"RedisConfig": { // redis的配置
"Nodes": [
{
"NodeName": "default",
"IsMasterSlave": false,
"Items": [
{
"Pool": 1,
"IsMaster": false,
"Server": "192.168.100.201",
"Port": 6379,
"AllowAdmin": true,
"ConnectTimeout": 4000,
"Ssl": true,
"Pwd": "xxxxx"
}
]
}
]
},
"HttpProxy": { // 网关中对外开放的服务
"Items": [
{
"Name": "A_DriverService"
},
{
"Name": "B_Service"
},
{
"Name": "C_Service"
},
{
"Name": "D_Service"
}
]
},
"FileServer": { // 文件服务器配置
"Items": []
},
"RpcClients": { //所有微服务的部署地址,静态配置不比写全,如果配置为zookeeper则不需要,服务会在启动时自动注册
"Clients": [
{
"ServerName": "A_Service",
"RouterType": 2,
"Items": [
{
"Pool": 1,
"Ip": "192.168.100.223",
"Port": 20002,
"ServerType": 2,
"Enable": true
}
]
},
{
"ServerName": "B_Service",
"RouterType": 2,
"Items": [
{
"Pool": 1,
"Ip": "192.168.100.223",
"Port": 20003,
"ServerType": 2,
"Enable": true
}
]
},
{
"ServerName": "C_Service",
"RouterType": 2,
"Items": [
{
"Pool": 1,
"Ip": "192.168.100.223",
"Port": 20004,
"ServerType": 2,
"Enable": true
}
]
},
{
"ServerName": "D_Service",
"RouterType": 2,
"Items": [
{
"Pool": 1,
"Ip": "192.168.100.223",
"Port": 20005,
"ServerType": 2,
"Enable": true
}
]
}
]
}
}