跳到主要内容

宿主总览

FreeKitModules 通过多个进程隔离 HTTP API、调度、消息处理和授权服务。它们可以共享数据库与业务核心程序集,但启动入口、配置和部署生命周期彼此独立。

主线宿主

宿主项目路径主要职责开发地址
FreeKit.Hostsrc/Services/Host/FreeKit.Host聚合 Identity、Member、CmsKit、Platform HTTP APIhttps://localhost:7000/kit_api
FreeKit.Job.Hostsrc/Services/Host/FreeKit.Job.HostFreeScheduler 任务与后台作业https://localhost:7002/job_api
FreeKit.MessageHandler.Hostsrc/Services/Host/FreeKit.MessageHandler.HostCAP 消息消费与后台处理https://localhost:7003/message_api
FreeKit.HealthCheckssrc/Services/Host/FreeKit.HealthChecks/FreeKit.HealthChecks独立 HealthChecks UIhttps://localhost:5005

端口来自各项目 Properties/launchSettings.json;容器部署会通过 ASPNETCORE_URLS 和 Compose 映射改写。

主 API 宿主

dotnet run --project src/Services/Host/FreeKit.Host --launch-profile https-dev

主宿主引用四个 *.HttpApi 项目。Program.cs 显式注册核心 startup,再通过 hostModules 注册 HttpApi startup 和 Controller 程序集。常用入口:

功能路径
Swagger{baseUrl}{pathBase}/swagger
RapiDoc{baseUrl}{pathBase}/r
Health{baseUrl}{pathBase}/health
FreeScheduler UI{baseUrl}{pathBase}/job/

后台宿主

Job 与 Message 使用 src/Services/Host/FreeKit.DI/E.cs 的核心模块映射,不引用四个 *.HttpApi 项目。这是拆分 HttpApi 的直接收益:后台进程可以调用 Application/Domain 能力,而不会加载业务 Controller 和 Hub。

启动示例:

dotnet run --project src/Services/Host/FreeKit.Job.Host --launch-profile https-dev
dotnet run --project src/Services/Host/FreeKit.MessageHandler.Host --launch-profile https-dev

三个业务宿主都调用 AddFreeKitObservability,但必须分别提供 OTLP 配置;只给主 Host 设置环境变量不会自动配置 Job 和 Message。

独立应用

应用项目/解决方案用途默认开发地址
Authauth/FreeKit.Auth.slnxOpenIddict OAuth2/OIDC 授权服务https://localhost:7005
BasicIdentitybasic/FreeKit.BasicIdentity.slnx轻量独立身份方案https://localhost:7000
CodeGencg/FreeKit.CodeGen.slnx代码生成后端与 UIhttp://localhost:5180

BasicIdentity 和主 FreeKit.Host 的默认 HTTPS 端口同为 7000,不能直接同时启动;需要为其中一个覆盖监听端口。

修改模块组合时

目标需要检查
后台宿主新增/移除核心模块FreeKit.DI/E.cs 与对应项目引用
主 API 新增业务模块核心 AddModulehostModulesextraAssemblies、HttpApi ProjectReference
只增加后台能力不应让 Job/Message 引用 *.HttpApi
新增 Swagger 分组Controller ApiExplorerSettings 与 Host Swagger endpoint 配置

相关文档