appsettings.json 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. {
  2. "Sers": {
  3. /* 通讯层配置 */
  4. "CL": {
  5. /* 共用配置,子项共用,覆写子项未指定的配置 */
  6. "Config": {
  7. /* 请求超时时间(单位ms,默认60000) */
  8. "requestTimeoutMs": 60000,
  9. /* 后台处理消息的线程个数(单位个,默认2) */
  10. "workThreadCount": 2,
  11. //HeartBeat
  12. /* 心跳检测时间间隔(单位ms,默认10000,若指定为0则不进行心跳检测) */
  13. "heartBeatIntervalMs": 10000,
  14. /* 心跳检测超时时间(单位ms,默认30000) */
  15. "heartBeatTimeoutMs": 30000,
  16. /* 心跳检测失败重试次数(单位次,默认10) */
  17. "heartBeatRetryCount": 10,
  18. /* 数据传输 加密协议,可多个,可不指定 */
  19. "//security": [
  20. {
  21. // SampleSecurity
  22. /* 在此Assembly中查找security */
  23. "assemblyFile": "Sers.Core.dll",
  24. /* the class of security in assemblyFile. 必须继承接口 Sers.Core.Util.StreamSecurity.ISecurity */
  25. "className": "Sers.Core.Util.StreamSecurity.Security.SampleSecurity",
  26. /* (x.2) config */
  27. /* 加密密钥 */
  28. "secret": "security"
  29. },
  30. {
  31. // SampleSecurity
  32. /* 若不指定assemblyFile和className 则默认为Sers.Core.Util.StreamSecurity.Security.SampleSecurity */
  33. "secret": "Two layer encryption"
  34. }
  35. ],
  36. /* 连接秘钥,用以验证连接安全性。服务端和客户端必须一致 */
  37. "secretKey": "SersCL"
  38. },
  39. /* one conn is one channel.can be multiable */
  40. "Server": [
  41. {
  42. //Ipc.NamedPipe
  43. /* (x.1) type */
  44. /* 在此Assembly中查找Builder */
  45. "assemblyFile": "Sers.CL.Ipc.NamedPipe.dll",
  46. /* the class of Builder in assemblyFile */
  47. //"className": "Sers.CL.Ipc.NamedPipe.OrganizeServerBuilder",
  48. /* (x.2) config */
  49. /* 命名管道名称。例如: "Sers.CL.Ipc" */
  50. "pipeName": "Sers.CL.Ipc.4501"
  51. },
  52. {
  53. // Socket.Iocp
  54. /* (x.1) type - Iocp */
  55. /* the class of Builder in assemblyFile */
  56. "className": "Sers.CL.Socket.Iocp.OrganizeServerBuilder",
  57. /* 通信模式。可为 "Simple" "Timer" "SpinWait"(默认) */
  58. //"mode": "Timer",
  59. /* (x.2) config */
  60. /* 服务端 监听地址。若不指定则监听所有网卡。例如: "127.0.0.1"、"sers.cloud"。*/
  61. //"host": "127.0.0.1",
  62. /* 服务端 监听端口号。例如: 4501 */
  63. "port": 4501
  64. },
  65. {
  66. // Socket.ThreadWait
  67. /* (x.1) type - Socket */
  68. /* the class of Builder in assemblyFile */
  69. //"className": "Sers.CL.Socket.ThreadWait.OrganizeServerBuilder",
  70. /* (x.2) config */
  71. /* 服务端 监听地址。若不指定则监听所有网卡。例如: "127.0.0.1"、"sers.cloud"。*/
  72. //"host": "127.0.0.1",
  73. /* 服务端 监听端口号。例如: 4501 */
  74. "port": 4501
  75. },
  76. {
  77. // Zmq.ThreadWait
  78. /* (x.1) type */
  79. /* 在此Assembly中查找Builder */
  80. "assemblyFile": "Sers.CL.ClrZmq.ThreadWait.dll",
  81. /* the class of Builder in assemblyFile */
  82. //"className": "Sers.CL.ClrZmq.ThreadWait.OrganizeServerBuilder",
  83. /* (x.2) config */
  84. /* 地址。例如: "tcp://*:4502" 、 "ipc://4502" */
  85. "endpoint": "tcp://*:4502"
  86. },
  87. {
  88. // WebSocket
  89. /* (x.1) type - Iocp */
  90. /* 在此Assembly中查找builder */
  91. "assemblyFile": "Sers.CL.WebSocket.dll",
  92. /* the class of builder in assemblyFile */
  93. //"className": "Sers.CL.WebSocket.OrganizeServerBuilder",
  94. /* (x.2) config */
  95. /* 服务端地址(默认为 "ws://0.0.0.0:4503") */
  96. "host": "ws://0.0.0.0:4503"
  97. },
  98. {
  99. // Zmq.FullDuplex
  100. /* (x.1) type */
  101. /* 在此Assembly中查找Builder */
  102. "assemblyFile": "Sers.CL.Zmq.FullDuplex.dll",
  103. /* the class of Builder in assemblyFile */
  104. //"className": "Sers.CL.Zmq.FullDuplex.OrganizeServerBuilder",
  105. /* (x.2) config */
  106. /* 地址。例如: "tcp://*:4504" 、 "ipc://4504" */
  107. "endpoint": "tcp://*:4504"
  108. },
  109. {
  110. //Ipc.SharedMemory
  111. /* (x.1) type - Ipc.SharedMemory */
  112. /* 在此Assembly中查找Builder */
  113. "assemblyFile": "Sers.CL.Ipc.SharedMemory.dll",
  114. /* the class of Builder in assemblyFile */
  115. //"className": "Sers.CL.Ipc.SharedMemory.OrganizeServerBuilder",
  116. /* (x.2) config */
  117. /* 共享内存名称。例如: "ipcTest" */
  118. "name": "ipcForStationDemo",
  119. /* 共享内存节点个数。例如: 64 */
  120. "nodeCount": 128,
  121. /* 共享内存节点大小。例如: 2048 */
  122. "nodeBufferSize": 102400
  123. },
  124. {
  125. /* (x.1) type - Ipc.SharedMemory */
  126. /* 在此Assembly中查找Builder */
  127. "assemblyFile": "Sers.CL.Ipc.SharedMemory.dll",
  128. /* the class of Builder in assemblyFile */
  129. //"className": "Sers.CL.Ipc.SharedMemory.OrganizeServerBuilder",
  130. /* (x.2) config */
  131. /* 共享内存名称。例如: "ipcTest" */
  132. "name": "ipcForRobot",
  133. /* 共享内存节点个数。例如: 64 */
  134. "nodeCount": 128,
  135. /* 共享内存节点大小。例如: 2048 */
  136. "nodeBufferSize": 102400
  137. }
  138. ]
  139. },
  140. // RpcData序列化模式。可不指定。默认为Text。
  141. // 可为 Newtonsoft、Text、BytePointor。
  142. // 效率依次递增。BytePointor 序列化为二进制数据而不是json字符串。
  143. "RpcDataSerializeMode": "Text",
  144. /* LocalApiService 配置,可不指定 */
  145. "LocalApiService": {
  146. /* 后台服务的线程个数(单位个,默认0,代表不开启服务)*/
  147. "workThreadCount": 1,
  148. /* 超时时间,若不指定则后台任务永不超时。(主动关闭超过此时间的任务,实际任务强制关闭的时间会在1倍超时时间到2倍超时时间内)。单位:ms。*/
  149. //"timeout_ms": 10000,
  150. /* 是否 输出本地Api的调用信息到(ApiTrace)Log文件。默认:false */
  151. "PrintTrace": false,
  152. /* 静态文件映射器。映射站点静态文件,可多个,可不指定 */
  153. "//staticFiles": [
  154. {
  155. /* api路由前缀,例如 "/demo/ui/*" */
  156. "route": "/demo/ui/*",
  157. /* api描述,静态文件描述 */
  158. "apiName": "demo站点静态文件",
  159. /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录。demo:"wwwroot/demo" */
  160. "rootPath": "wwwroot/demo",
  161. /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"contentTypeMap.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
  162. "contentTypeMapFile": "contentTypeMap.json",
  163. /* 回应静态文件时额外添加的http回应头。可不指定。 */
  164. "responseHeaders": {
  165. //设置浏览器静态文件缓存3600秒
  166. "Cache-Control": "public,max-age=3600"
  167. }
  168. }
  169. ],
  170. /* 默认站点名称,可多个,可不指定 */
  171. //"apiStationNames": [ "demo" ],
  172. /* Api加载器配置 */
  173. "//ApiLoaders": [
  174. {
  175. /* 在此Assembly中查找api加载器(如 Sers.Core.dll 、Sers.NetcoreLoader.dll 、 Sers.Serslot.dll ) */
  176. //"loader_assemblyFile": "Sers.Core.dll",
  177. /* 加载器的类名,可为 Sers.SersLoader.ApiLoader 、 Sers.NetcoreLoader.ApiLoader、 Sers.Serslot.ApiLoader 等。若不指定则默认为"Sers.SersLoader.ApiLoader" */
  178. //"loader_className": "Sers.SersLoader.ApiLoader",
  179. //(通过反射从此包中获取要加载的api)
  180. /* 在此Assembly中查找服务(如 Did.SersLoader.Demo.dll)(assembly、assemblyFile、assemblyName 指定任一即可) */
  181. "assemblyFile": "Did.SersLoader.Demo.dll",
  182. /* 在此Assembly中查找服务(如 Did.SersLoader.Demo)(assembly、assemblyFile、assemblyName 指定任一即可) */
  183. //"assemblyName": "Did.SersLoader.Demo",
  184. /* 强制指定ApiStation名称。可不指定。(优先级从高到低: apiStationName_Force 、 在代码上的SsStationNameAttribute特性指定 、 apiStationName 、 appsettings.json指定) */
  185. //"apiStationName_Force": "",
  186. /* ApiStation名称。可不指定。(优先级从高到低: apiStationName_Force 、 在代码上的SsStationNameAttribute特性指定 、 apiStationName 、 appsettings.json指定) */
  187. "apiStationName": "demo"
  188. /* 强制路由前缀,例如:"demo/v1"。可不指定。(优先级从高到低: routePrefix_Force、在代码上的SsRoutePrefixAttribute特性指定 、 routePrefix) */
  189. //"routePrefix_Force": "",
  190. /* 路由前缀,例如:"demo/v1"。可不指定。(优先级从高到低: routePrefix_Force、在代码上的SsRoutePrefixAttribute特性指定 、 routePrefix ) */
  191. //"routePrefix": ""
  192. }
  193. ],
  194. /* 调用Api时的自定义Scope对象。可不指定。事件顺序为 OnCreateScope -> BeforeCallApi -> OnDispose */
  195. "//OnCreateScope": [
  196. {
  197. /* 在此Assembly中加载类 */
  198. "assemblyFile": "Sers.ApiTrace.dll",
  199. /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.ApiScope.IApiScope */
  200. "className": "Sers.ApiTrace.ApiScope"
  201. }
  202. ],
  203. /* 调用api前的事件,可不指定。事件顺序为 OnCreateScope -> BeforeCallApi -> OnDispose */
  204. "//BeforeCallApi": [
  205. {
  206. /* 在此Assembly中加载类 */
  207. "assemblyFile": "Sers.Core.dll",
  208. /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
  209. "className": "Bearer",
  210. //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
  211. /* 验证at接口的地址 */
  212. "api_verifyAt": "/AuthCenter/account/verifyAt",
  213. /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
  214. "api_httpMethod": "POST"
  215. },
  216. {
  217. //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo)
  218. "className": "AccountInCookie",
  219. "account": [
  220. {
  221. "userToken": "admin_123456",
  222. //"CallerSource": "Internal",
  223. "userInfo": {
  224. "name": "超级管理员",
  225. "入口": "Gover网关"
  226. }
  227. }
  228. ]
  229. }
  230. ]
  231. },
  232. /* ServiceStation配置,可不指定 */
  233. "ServiceStation": {
  234. /* 自动上报cpu Usage。不指定则不上报 */
  235. "//UsageReporter": {
  236. /* 上报时间间隔(单位:秒) */
  237. "intervalSecond": 2
  238. },
  239. /* serviceStation站点信息 */
  240. "serviceStationInfo": {
  241. /* 服务站点名称 */
  242. "serviceStationName": "ServiceCenter",
  243. /* 服务站点版本信息,若不指定则为入口链接库的版本号 */
  244. //"stationVersion": "2.1.1",
  245. /* [json]服务站点额外信息,可不指定 */
  246. "info": null
  247. }
  248. },
  249. /* ServiceCenter 配置,可不指定 */
  250. "ServiceCenter": {
  251. /* 是否 输出Api注册事件到(Info)Log文件。默认:true */
  252. "ApiRegistEvent_Print": true,
  253. /* api路由管理方式,可不指定。可为:"RESTful","IgnoreHttpMethod"。若不指定或未指定有效值,则默认为"RESTful" */
  254. //"ApiRouteType": "IgnoreHttpMethod",
  255. //调用api前的事件,可不指定
  256. "//BeforeCallApi": [
  257. {
  258. /* 在此Assembly中加载类 */
  259. "assemblyFile": "Sers.Core.dll",
  260. /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
  261. "className": "Bearer",
  262. //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
  263. /* 验证at接口的地址 */
  264. "api_verifyAt": "/AuthCenter/account/verifyAt",
  265. /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
  266. "api_httpMethod": "POST"
  267. },
  268. {
  269. //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo)
  270. //"className": "AccountInCookie",
  271. "account": [
  272. {
  273. "userToken": "admin_123456",
  274. //"CallerSource": "Internal",
  275. "userInfo": {
  276. "name": "超级管理员",
  277. "入口": "Gover网关"
  278. }
  279. }
  280. ]
  281. }
  282. ]
  283. },
  284. /* 动态加载的App事件 */
  285. "AppEvent": [
  286. {
  287. /* 在此Assembly中加载类 */
  288. "assemblyFile": "Sers.Gover.Apm.Zipkin.dll",
  289. /* 动态加载的类名,必须继承接口 Sers.Core.Module.App.AppEvent.IAppEvent */
  290. //"className": "Sers.Gover.Apm.Zipkin.AppEvent",
  291. //启用Zipkin链路追踪(自动提交应用调用信息)
  292. /* 配置 */
  293. "SamplingRate": "1.0",
  294. "zipkinCollectorUrl": "http://sers.cloud:9411",
  295. /* 若不指定则默认为ServiceCenter */
  296. "rpcName": "ServiceCenter",
  297. "tags": {
  298. // 可为 requestRpc requestData responseRpc responseData
  299. "traceName": "demoTrace",
  300. "route": "{{requestRpc.route}}",
  301. "{{requestRpc.route}}": "route",
  302. "url": "{{requestRpc.http.url}}",
  303. "method": "{{requestRpc.http.method}}",
  304. "requestRpc": "{{requestRpc}}",
  305. //"requestData": "{{requestData}}",
  306. "responseRpc": "{{responseRpc}}",
  307. "responseState": "{{responseRpc.http.headers.responseState}}",
  308. "responseError_Base64": "{{responseRpc.http.headers.responseError_Base64}}"
  309. //"responseData": "{{responseData}}",
  310. //"responseData.error": "{{responseData.error}}"
  311. }
  312. }
  313. ],
  314. /* 网关配置。若不指定,则不开启网关服务 */
  315. "Gateway": {
  316. /* Rpc配置,可不指定 */
  317. "Rpc": {
  318. /* 网关转发的请求中的rpc 信息中的 CallerSource。(暗指调用来源,默认"OutSide") */
  319. //"CallerSource": "OutSide"
  320. },
  321. "WebHost": {
  322. /* url,可多个 */
  323. "urls": [ "http://*:4580" ],
  324. /* 是否允许跨域访问,默认true */
  325. "allowAnyOrigin": true,
  326. /* 把请求的ip地址、端口号复制到请求头中的前缀。若不指定则不复制。 */
  327. "prefixOfCopyIpToHeader": "Sers-Gateway-",
  328. /* http回应中的默认Content-Type。若不指定则默认为 "application/json; charset="+Serialization.Instance.charset */
  329. "//ResponseDefaultContentType": "application/json; charset=UTF-8",
  330. /* 映射静态文件。若不指定则不映射静态文件 */
  331. "staticFiles": {
  332. /* 请求路径(可不指定)。demo:"/file/static"。The relative request path that maps to static resources */
  333. //"requestPath": "/file",
  334. /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则为默认路径(wwwroot)。demo:"wwwroot/demo" */
  335. //"rootPath": "wwwroot",
  336. /* 默认页面(可不指定)。An ordered list of file names to select by default. List length and ordering may affect performance */
  337. "defaultFileNames": [ "index.html" ],
  338. /* 是否可浏览目录(default false)。Enables directory browsing */
  339. //"useDirectoryBrowser": false,
  340. /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"contentTypeMap.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
  341. "contentTypeMapFile": "contentTypeMap.json",
  342. /* 回应静态文件时额外添加的http回应头。可不指定。 */
  343. "responseHeaders": {
  344. //设置浏览器静态文件缓存3600秒
  345. "Cache-Control": "public,max-age=3600"
  346. }
  347. }
  348. },
  349. //调用api前的事件,可不指定
  350. "BeforeCallApi": [
  351. {
  352. /* 在此Assembly中加载类 */
  353. "assemblyFile": "Sers.Core.dll",
  354. /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
  355. //"className": "Bearer",
  356. //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
  357. /* 验证at接口的地址 */
  358. "api_verifyAt": "/AuthCenter/account/verifyAt",
  359. /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
  360. "api_httpMethod": "POST"
  361. },
  362. {
  363. //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo)
  364. "className": "AccountInCookie",
  365. "account": [
  366. {
  367. "userToken": "admin_123456",
  368. "CallerSource": "Internal",
  369. "userInfo": {
  370. "name": "Gover管理员",
  371. "入口": "Gover网关"
  372. }
  373. }
  374. ]
  375. }
  376. ],
  377. /* 服务限流配置,可不指定 */
  378. "rateLimit": [
  379. {
  380. /* 服务限流key,标识一个限流服务,必须唯一 */
  381. "rateLimitKey": "rate",
  382. /* 固定时间窗口限流。在单位时间(msInterval)内限制最大请求数量为reqLimit。超出数量的请求将被拒绝 */
  383. "rateLimitType": "FixedWindow",
  384. /* 单位时间内最大请求数量(个)*/
  385. "reqLimit": 100000,
  386. /* 单位时间长度(单位:ms)*/
  387. "msInterval": 1000
  388. }
  389. ]
  390. }
  391. },
  392. /* Vit工具配置,可不指定 */
  393. "Vit": {
  394. /* 日志配置,可不指定 */
  395. "Logger": {
  396. /* print the log to Log/*.txt default:true */
  397. "PrintToTxt": true,
  398. /* print the log to console. default:false */
  399. "PrintToConsole": true
  400. },
  401. /* 队列模式,可不指定。可为 BlockingCollection(默认)、 ConsumerCache_BlockingCollection(高性能) */
  402. "ConsumerMode": "BlockingCollection",
  403. /* 序列化配置,可不指定 */
  404. "Serialization": {
  405. /* 序列化字符编码。可不指定,默认 UTF8。只可为 UTF7,UTF8,UTF32,ASCII,Unicode。 */
  406. "Encoding": "UTF8",
  407. /* 时间序列化格式。可不指定,默认 "yyyy-MM-dd HH:mm:ss" */
  408. "DateTimeFormat": "yyyy-MM-dd HH:mm:ss"
  409. },
  410. "//Kestrel": {
  411. /* (int64) the maximum allowed size of any request body in bytes. When set to null, the maximum request body size is unlimited. */
  412. "MaxRequestBodySize": 2000000000,
  413. /* (int32) A limit on the length of individual form values. Forms containing values that exceed this limit will throw an System.IO.InvalidDataException when parsed. */
  414. "ValueLengthLimit": 2000000000,
  415. /* (int64) A limit for the length of each multipart body. Forms sections that exceed this limit will throw an System.IO.InvalidDataException when parsed. */
  416. "MultipartBodyLengthLimit": 2000000000
  417. }
  418. }
  419. }