appsettings.json 20 KB

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