快速入门指南
以当前默认宿主 src\Services\Host\FreeKit.Host 为主,从仓库代码直接对应到可访问入口。
前置要求
必需环境
- .NET SDK 10.0+
- Git
- MySQL 8.x、SQL Server、PostgreSQL 或 SQLite 之一
- Redis 7.x
按需启用
- RabbitMQ:CAP 消息总线相关功能
- MeiliSearch:CmsKit 搜索、搜索建议、增量索引
- Docker Desktop:使用 Compose 一键启动整套依赖
方式一:本地直接运行默认宿主
1. 克隆并还原
git clone https://github.com/luoyunchong/FreeKitModules.git
cd FreeKitModules
dotnet restore FreeKitModules.sln
2. 修改主宿主配置
编辑 src\Services\Host\FreeKit.Host\appsettings.Development.json,至少确认这些配置段可用:
{
"ASPNETCORE_PATHBASE": "/kit_api",
"ConnectionStrings": {
"DefaultDB": "0",
"MySql": "Data Source=localhost;Port=3306;User ID=root;Password=<your-password>;Initial Catalog=freekit;Charset=utf8mb4;SslMode=none;",
"Redis": "localhost:6379,password=<your-password>,defaultDatabase=1"
},
"ShortUrlConnectionStrings": {
"MySql": "Data Source=localhost;Port=3306;User ID=root;Password=<your-password>;Initial Catalog=freekit_shorturl;Charset=utf8mb4;SslMode=none;"
},
"LogConnectionStrings": {
"MySql": "Data Source=localhost;Port=3306;User ID=root;Password=<your-password>;Initial Catalog=freekit_log;Charset=utf8mb4;SslMode=none;"
}
}
如果暂时不使用搜索,可保持 MeiliSearch.Enable = false。
3. 启动主 API 宿主
dotnet run --project src\Services\Host\FreeKit.Host --launch-profile https-dev
launchSettings.json 中的本地默认地址为:
https://localhost:7002/kit_apihttp://localhost:5002/kit_api
4. 验证入口
| 入口 | 地址 |
|---|---|
| Swagger UI | https://localhost:7002/kit_api/swagger |
| RapiDoc | https://localhost:7002/kit_api/r |
| 健康检查 | https://localhost:7002/kit_api/health |
| FreeScheduler UI | https://localhost:7002/kit_api/job |
| 在线用户 Hub | https://localhost:7002/kit_api/hubs/onlineuser |
| 通知 Hub | https://localhost:7002/kit_api/hubs/notifications |
方式二:本地运行三类默认宿主
如果你需要完整体验任务与消息处理,可分别启动:
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
dotnet run --project src\Services\Host\FreeKit.HealthChecks\FreeKit.HealthChecks
对应本地默认地址:
| 宿主 | 本地地址 |
|---|---|
FreeKit.Job.Host | https://localhost:7000/job_api |
FreeKit.MessageHandler.Host | https://localhost:7003/message_api |
FreeKit.HealthChecks | https://localhost:5005 |
方式三:Docker Compose 一键启动
仓库已提供统一脚本:
build\run_freekit_pro_modules.bat
或:
bash build/run_freekit_pro_modules.bash
脚本会优先读取:
build/compose/freekit_pro_modules/.env.local- 若不存在则回退到
build/compose/freekit_pro_modules/.env
Compose 默认启动的服务:
mysqlredisrabbitmqmeilisearchhostjobmessage
容器模式默认访问地址:
| 入口 | 地址 |
|---|---|
| 主 API Swagger | http://localhost:18080/kit_api/swagger |
| 主 API RapiDoc | http://localhost:18080/kit_api/r |
| Job Swagger | http://localhost:18081/job_api/swagger |
| Job FreeScheduler UI | http://localhost:18081/job_api/job |
| Message Swagger | http://localhost:18082/message_api/swagger |
| RabbitMQ 管理台 | http://localhost:15673 |
| MeiliSearch | http://localhost:17700 |
首次运行时会发生什么
默认宿主调用 builder.UseFreeKit(moduleTypeMap: E.Modules, ...) 装载模块,并在启动后执行:
app.MapModules().Init()await app.MigrationStartAsync()- 各模块
IModuleStartup.Configure(...)中的FreeSql CodeFirst SyncStructure(...)
这意味着开发环境下,模块会在应用启动时自动同步表结构。
默认模块清单
主宿主当前默认注册模块来自 src\Services\Host\FreeKit.DI\E.cs:
- Identity
- Identity.Infrastructure
- Platform
- Holiday
- ToDo
- CmsKit
- ToolKit
- IM
- Member
- Short
Mall 代码存在于仓库中,但当前默认主宿主未启用。