appsettings.json 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. {
  2. "Sers": {
  3. /* 通讯层配置 */
  4. "CL": {
  5. /* 共用配置,子项共用,覆写子项未指定的配置 */
  6. "Config": {
  7. /* 请求超时时间(单位ms,默认60000) */
  8. "requestTimeoutMs": 60000,
  9. /* 后台处理消息的线程个数(单位个,默认2) */
  10. "workThreadCount": 1,
  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. /* 通信模式(默认值:Simple)。可为 Simple、Timer、SpinWait */
  29. //"mode": "Timer",
  30. /* (x.2) conn config */
  31. /* 服务端 监听地址。若不指定则监听所有网卡。例如: "127.0.0.1"、"sers.com"。*/
  32. //"host": "127.0.0.1",
  33. /* 服务端 监听端口号。例如: 4501 */
  34. "port": 4501
  35. }
  36. ]
  37. },
  38. // RpcData序列化模式。可不指定。默认为Text。
  39. // 可为 Newtonsoft、Text、BytePointor。
  40. // 效率依次递增。BytePointor 序列化为二进制数据而不是json字符串。
  41. "RpcDataSerializeMode": "BytePointor",
  42. /* LocalApiService 配置,可不指定 */
  43. "LocalApiService": {
  44. /* 后台服务的线程个数(单位个,默认0,代表不开启服务)*/
  45. "workThreadCount": 8,
  46. /* 超时时间,若不指定则后台任务永不超时。(主动关闭超过此时间的任务,实际任务强制关闭的时间会在1倍超时时间到2倍超时时间内)。单位:ms。*/
  47. //"timeout_ms": 10000,
  48. /* 是否 输出本地Api的调用信息到(ApiTrace)Log文件。默认:false */
  49. "PrintTrace": false,
  50. /* 默认站点名称,可多个,可不指定 */
  51. //"apiStationNames": [ "demo" ],
  52. /* Api加载器配置 */
  53. "ApiLoaders": [
  54. {
  55. //(通过反射从此包中获取要加载的api)
  56. /* 在此Assembly中查找服务(如 App.StationDemo.Station.dll)(assembly、assemblyFile、assemblyName 指定任一即可) */
  57. "assemblyFile": "Did.SersLoader.Demo.dll",
  58. /* ApiStation名称。可不指定。(优先级从高到低: apiStationName_Force 、 在代码上的SsStationNameAttribute特性指定 、 apiStationName 、 appsettings.json指定) */
  59. "apiStationName": "demo"
  60. },
  61. {
  62. /* ApiStation名称。可不指定。(优先级从高到低: apiStationName_Force 、 在代码上的SsStationNameAttribute特性指定 、 apiStationName 、 appsettings.json指定) */
  63. "apiStationName": "_robot_",
  64. /* 在此Assembly中查找服务(如 App.StationDemo.Station.dll)(assembly、assemblyFile、assemblyName 指定任一即可) */
  65. "assemblyFile": "App.Robot.Station.dll"
  66. }
  67. ],
  68. //调用api前的事件,可不指定
  69. "//BeforeCallApi": [
  70. {
  71. //Bearer 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
  72. "className": "Bearer",
  73. /* 验证at接口的地址 */
  74. "api_verifyAt": "/AuthCenter/account/verifyAt",
  75. /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
  76. "api_httpMethod": "POST"
  77. },
  78. {
  79. //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo)
  80. "className": "AccountInCookie",
  81. "account": [
  82. {
  83. "userToken": "admin_123456",
  84. //"CallerSource": "Internal",
  85. "userInfo": {
  86. "name": "超级管理员",
  87. "入口": "Gover网关"
  88. }
  89. }
  90. ]
  91. }
  92. ]
  93. },
  94. /* ServiceStation配置,可不指定 */
  95. "ServiceStation": {
  96. /* 自动上报cpu Usage。不指定则不上报 */
  97. "//UsageReporter": {
  98. /* 上报时间间隔(单位:秒) */
  99. "intervalSecond": 2
  100. },
  101. /* serviceStation站点信息 */
  102. "serviceStationInfo": {
  103. /* 服务站点名称 */
  104. "serviceStationName": "ServiceCenter",
  105. /* 服务站点版本信息,若不指定则为入口链接库的版本号 */
  106. //"stationVersion": "2.1.1",
  107. /* [json]服务站点额外信息,可不指定 */
  108. "info": null
  109. }
  110. },
  111. /* ServiceCenter 配置,可不指定 */
  112. "ServiceCenter": {
  113. /* 是否 输出Api注册事件到(Info)Log文件。默认:true */
  114. "ApiRegistEvent_Print": true,
  115. /* api路由管理方式,可不指定。可为:"RESTful","IgnoreHttpMethod"。若不指定或未指定有效值,则默认为"RESTful" */
  116. //"ApiRouteType": "IgnoreHttpMethod",
  117. //调用api前的事件,可不指定
  118. "BeforeCallApi": [
  119. {
  120. //Bearer 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
  121. //"className": "Bearer",
  122. /* 验证at接口的地址 */
  123. "api_verifyAt": "/AuthCenter/account/verifyAt",
  124. /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
  125. "api_httpMethod": "POST"
  126. },
  127. {
  128. //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo)
  129. //"className": "AccountInCookie",
  130. "account": [
  131. {
  132. "userToken": "admin_123456",
  133. //"CallerSource": "Internal",
  134. "userInfo": {
  135. "name": "超级管理员",
  136. "入口": "Gover网关"
  137. }
  138. }
  139. ]
  140. }
  141. ]
  142. },
  143. /* 网关配置(同目录下可以指定mappings.json文件) ,可不指定 */
  144. "Gateway": {
  145. /* Rpc配置,可不指定 */
  146. "Rpc": {
  147. /* 网关转发的请求中的rpc 信息中的 CallerSource。(暗指调用来源,默认"OutSide") */
  148. //"CallerSource": "OutSide"
  149. },
  150. "WebHost": {
  151. /* url,可多个 */
  152. "urls": [ "http://*:4580" ],
  153. /* http回应中的默认Content-Type。若不指定则默认为 "application/json; charset="+Serialization.Instance.charset */
  154. "//ResponseDefaultContentType": "application/json; charset=UTF-8",
  155. /* 映射静态文件。若不指定则不映射静态文件 */
  156. "staticFiles": {
  157. /* 请求路径(可不指定)。demo:"/file/static"。The relative request path that maps to static resources */
  158. //"requestPath": "/file",
  159. /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录下的wwwroot文件夹。demo:"wwwroot/demo" */
  160. "rootPath": "wwwroot",
  161. /* 默认页面(可不指定)。An ordered list of file names to select by default. List length and ordering may affect performance */
  162. "defaultFileNames": [ "index.html" ],
  163. /* 是否可浏览目录(default false)。Enables directory browsing */
  164. //"useDirectoryBrowser": false,
  165. /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"contentTypeMap.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
  166. "contentTypeMapFile": "contentTypeMap.json",
  167. /* 回应静态文件时额外添加的http回应头。可不指定。 */
  168. "responseHeaders": {
  169. //设置浏览器静态文件缓存3600秒
  170. "Cache-Control": "public,max-age=3600"
  171. }
  172. }
  173. },
  174. //调用api前的事件,可不指定
  175. "BeforeCallApi": [
  176. {
  177. //Bearer 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
  178. //"className": "Bearer",
  179. /* 验证at接口的地址 */
  180. "api_verifyAt": "/AuthCenter/account/verifyAt",
  181. /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
  182. "api_httpMethod": "POST"
  183. },
  184. {
  185. //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo)
  186. "className": "AccountInCookie",
  187. "account": [
  188. {
  189. "userToken": "admin_123456",
  190. "CallerSource": "Internal",
  191. "userInfo": {
  192. "name": "Gover管理员",
  193. "入口": "Gover网关"
  194. }
  195. }
  196. ]
  197. }
  198. ],
  199. /* 服务限流配置,可不指定 */
  200. "rateLimit": [
  201. {
  202. /* 服务限流key,标识一个限流服务,必须唯一 */
  203. "rateLimitKey": "rate",
  204. /* 固定时间窗口限流。在单位时间(msInterval)内限制最大请求数量为reqLimit。超出数量的请求将被拒绝 */
  205. "rateLimitType": "FixedWindow",
  206. /* 单位时间内最大请求数量(个)*/
  207. "reqLimit": 100000,
  208. /* 单位时间长度(单位:ms)*/
  209. "msInterval": 1000
  210. }
  211. ]
  212. }
  213. },
  214. /* Vit工具配置,可不指定 */
  215. "Vit": {
  216. /* 日志配置,可不指定 */
  217. "Logger": {
  218. /* print the log to Log/*.txt default:true */
  219. "PrintToTxt": true,
  220. /* print the log to console. default:false */
  221. "PrintToConsole": true
  222. },
  223. /* 队列模式,可不指定。可为 BlockingCollection(默认)、 ConsumerCache_BlockingCollection(高性能) */
  224. "ConsumerMode": "ConsumerCache_BlockingCollection",
  225. /* 序列化配置,可不指定 */
  226. "Serialization": {
  227. /* 序列化字符编码。可不指定,默认 UTF8。只可为 UTF7,UTF8,UTF32,ASCII,Unicode。 */
  228. "Encoding": "UTF8",
  229. /* 时间序列化格式。可不指定,默认 "yyyy-MM-dd HH:mm:ss" */
  230. "DateTimeFormat": "yyyy-MM-dd HH:mm:ss"
  231. },
  232. "//Kestrel": {
  233. /* (int64) the maximum allowed size of any request body in bytes. When set to null, the maximum request body size is unlimited. */
  234. "MaxRequestBodySize": 2000000000,
  235. /* (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. */
  236. "ValueLengthLimit": 2000000000,
  237. /* (int64) A limit for the length of each multipart body. Forms sections that exceed this limit will throw an System.IO.InvalidDataException when parsed. */
  238. "MultipartBodyLengthLimit": 2000000000
  239. }
  240. }
  241. }