appsettings.json 21 KB

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