appsettings.json 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. {
  2. /* asp.net core 原始web服务配置 */
  3. "server": {
  4. "urls": [ "http://localhost:4513" ]
  5. },
  6. "Logging": {
  7. "LogLevel": {
  8. "Default": "Warning"
  9. }
  10. },
  11. "AllowedHosts": "*",
  12. "Sers": {
  13. /* 通讯层配置 */
  14. "CL": {
  15. /* 共用配置,子项共用,覆写子项未指定的配置 */
  16. "Config": {
  17. "workThread": {
  18. // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
  19. "mode": "LongThread",
  20. /* 后台处理消息的线程个数(单位个,默认2) */
  21. "threadCount": 2,
  22. /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
  23. "maxThreadCount": 100,
  24. /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
  25. "pendingQueueLength": 100000,
  26. /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
  27. "timeoutMs": 300000
  28. },
  29. /* 请求超时时间(单位ms,默认300000) */
  30. "requestTimeoutMs": 300000,
  31. /* 连接秘钥,用以验证连接安全性。服务端和客户端必须一致 */
  32. "secretKey": "SersCL"
  33. },
  34. /* one conn is one channel.can be multiable */
  35. "Client": [
  36. {
  37. // Socket.Iocp
  38. /* (x.1) type - Iocp */
  39. /* the class of builder in assemblyFile */
  40. "className": "Sers.CL.Socket.Iocp.OrganizeClientBuilder",
  41. /* 通信模式(默认值:Simple)。可为 Simple、Timer、ThreadWait */
  42. //"mode": "ThreadWait",
  43. /* (x.2) conn config */
  44. /* 服务端 host地址。例如: "127.0.0.1"、"sers.cloud" */
  45. "host": "127.0.0.1",
  46. /* 服务端 监听端口号。例如: 4501 */
  47. "port": 4501
  48. }
  49. ]
  50. },
  51. // RpcData序列化模式。可不指定。默认为Text。
  52. // 可为 Newtonsoft、Text、BytePointor。
  53. // 效率依次递增。BytePointor 序列化为二进制数据而不是json字符串。
  54. "RpcDataSerializeMode": "Text",
  55. /* LocalApiService 配置,可不指定 */
  56. "LocalApiService": {
  57. /* 是否 输出本地Api的调用信息到(ApiTrace)Log文件。默认:false */
  58. "PrintTrace": false,
  59. "workThread": {
  60. // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
  61. "mode": "LongThread",
  62. /* 后台服务的线程个数(单位个,默认16)(0代表不开启服务) */
  63. "threadCount": 16,
  64. /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
  65. "maxThreadCount": 100,
  66. /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
  67. "pendingQueueLength": 100000,
  68. /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
  69. "timeoutMs": 300000
  70. },
  71. /* 静态文件映射器。映射站点静态文件,可多个,可不指定 */
  72. "//staticFiles": [
  73. {
  74. /* api路由前缀,例如 "/demo/ui/*" */
  75. "route": "/demo/ui/*",
  76. /* api描述,静态文件描述 */
  77. "apiName": "demo站点静态文件",
  78. /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录。demo:"wwwroot/demo" */
  79. "rootPath": "wwwroot/demo",
  80. /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"contentTypeMap.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
  81. "contentTypeMapFile": "contentTypeMap.json",
  82. /* 回应静态文件时额外添加的http回应头。可不指定。 */
  83. "responseHeaders": {
  84. //设置浏览器静态文件缓存3600秒
  85. "Cache-Control": "public,max-age=3600"
  86. }
  87. }
  88. ],
  89. /* 默认站点名称,可多个,可不指定 */
  90. "//apiStationNames": [ "demo" ],
  91. /* Api加载器配置 */
  92. "//ApiLoaders": [
  93. {
  94. /* 在此Assembly中查找api加载器(如 Sers.Core.dll 、Sers.NetcoreLoader.dll 、 Sers.Serslot.dll ) */
  95. //"loader_assemblyFile": "Sers.Core.dll",
  96. /* 加载器的类名,可为 Sers.SersLoader.ApiLoader 、 Sers.NetcoreLoader.ApiLoader、 Sers.Serslot.ApiLoader 等。若不指定则默认为"Sers.SersLoader.ApiLoader" */
  97. //"loader_className": "Sers.SersLoader.ApiLoader",
  98. //(通过反射从此包中获取要加载的api)
  99. /* 在此Assembly中查找服务(如 Did.SersLoader.Demo.dll)(assembly、assemblyFile、assemblyName 指定任一即可) */
  100. "assemblyFile": "Did.SersLoader.Demo.dll",
  101. /* 在此Assembly中查找服务(如 Did.SersLoader.Demo)(assembly、assemblyFile、assemblyName 指定任一即可) */
  102. //"assemblyName": "Did.SersLoader.Demo",
  103. /* 强制指定ApiStation名称。可不指定。(优先级从高到低: apiStationName_Force 、 在代码上的SsStationNameAttribute特性指定 、 apiStationName 、 appsettings.json指定) */
  104. //"apiStationName_Force": "",
  105. /* ApiStation名称。可不指定。(优先级从高到低: apiStationName_Force 、 在代码上的SsStationNameAttribute特性指定 、 apiStationName 、 appsettings.json指定) */
  106. "apiStationName": "demo"
  107. /* 强制路由前缀,例如:"demo/v1"。可不指定。(优先级从高到低: routePrefix_Force、在代码上的SsRoutePrefixAttribute特性指定 、 routePrefix) */
  108. //"routePrefix_Force": "",
  109. /* 路由前缀,例如:"demo/v1"。可不指定。(优先级从高到低: routePrefix_Force、在代码上的SsRoutePrefixAttribute特性指定 、 routePrefix ) */
  110. //"routePrefix": ""
  111. }
  112. ],
  113. /* 调用Api时的自定义Scope对象。可不指定。事件顺序为 OnCreateScope -> BeforeCallApi -> OnDispose */
  114. "//OnCreateScope": [
  115. {
  116. /* 在此Assembly中加载类 */
  117. "assemblyFile": "Sers.ApiTrace.dll",
  118. /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.ApiScope.IApiScopeEvent */
  119. "className": "Sers.ApiTrace.ApiScope"
  120. }
  121. ],
  122. /* 调用api前的事件,可不指定。事件顺序为 OnCreateScope -> BeforeCallApi -> OnDispose */
  123. "//BeforeCallApi": [
  124. {
  125. /* 在此Assembly中加载类 */
  126. //"assemblyFile": "Sers.Core.dll",
  127. /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
  128. "className": "Bearer",
  129. //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
  130. /* 验证at接口的地址 */
  131. "api_verifyAt": "/AuthCenter/account/verifyAt",
  132. /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
  133. "api_httpMethod": "POST"
  134. },
  135. {
  136. //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo)
  137. "className": "AccountInCookie",
  138. "account": [
  139. {
  140. "userToken": "admin_123456",
  141. //"CallerSource": "Internal",
  142. "userInfo": {
  143. "name": "超级管理员",
  144. "入口": "Gover网关"
  145. }
  146. }
  147. ]
  148. }
  149. ]
  150. },
  151. /* ServiceStation配置,可不指定 */
  152. "ServiceStation": {
  153. /* 自动上报cpu Usage。不指定则不上报 */
  154. "//UsageReporter": {
  155. /* 上报时间间隔(单位:秒) */
  156. "intervalSecond": 2
  157. },
  158. /* 服务中心注册配置。在向服务中心注册站点前 是否打印(Logger.Info)请求参数。默认:false */
  159. "StationRegist_PrintRegistArg": false,
  160. /* serviceStation站点信息 */
  161. "serviceStationInfo": {
  162. "serviceStationName": "SerslotDemo",
  163. /* 服务站点版本信息,若不指定则为入口链接库的版本号 */
  164. "//stationVersion": "1.1.9.0",
  165. /* [json]服务站点额外信息,可不指定 */
  166. "info": null
  167. }
  168. }
  169. },
  170. /* Vit工具配置,可不指定 */
  171. "Vit": {
  172. /* 日志配置,可不指定 */
  173. "Logger": {
  174. /* print the log to Log/*.txt default:true */
  175. "PrintToTxt": true,
  176. /* print the log to console. default:true */
  177. "PrintToConsole": true
  178. },
  179. /* 序列化配置,可不指定 */
  180. "Serialization": {
  181. /* 序列化字符编码。可不指定,默认 UTF8。只可为 UTF7,UTF8,UTF32,ASCII,Unicode。 */
  182. "Encoding": "UTF8",
  183. /* 时间序列化格式。可不指定,默认 "yyyy-MM-dd HH:mm:ss" */
  184. "DateTimeFormat": "yyyy-MM-dd HH:mm:ss"
  185. }
  186. },
  187. "serslot": {
  188. /* 额外api。SsApiDesc格式。除了系统api外,可以指定额外api。若指定返回数据(reply),则直接返回数据;若不指定返回数据,则由host进行处理 */
  189. "//extApi": [
  190. { //为 SsApiDesc格式
  191. "description": "首页",
  192. //路由(可为泛接口,如 "/a/*" )
  193. "route": "/index.html",
  194. //扩展配置(json)
  195. "extendConfig": {
  196. //请求方式,若不指定则默认支持所有方式(demo: POST、GET、DELETE、PUT等)
  197. "httpMethod": "GET",
  198. //返回数据(可为数值、字符串、对象、数组)。若不指定,则由host进行处理
  199. "reply": { "hello": "sers" },
  200. //系统生成的接口文字描述
  201. "sysDesc": "method:GET"
  202. }
  203. },
  204. {
  205. //路由(可为泛接口,如 "/a/*" )
  206. "route": "/*"
  207. }
  208. ]
  209. }
  210. }