appsettings.json 17 KB

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