appsettings.json 13 KB

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