Files
backend/cmd/server/main.go

38 lines
903 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// @title CarrotSkin API
// @version 1.0
// @description Minecraft皮肤站后端API
// @host localhost:8080
// @BasePath /api/v1
// @securityDefinitions.apikey BearerAuth
// @in header
// @name Authorization
package main
import (
"log"
"carrotskin/internal/app"
"carrotskin/pkg/config"
"go.uber.org/fx"
)
// main 应用入口。通过 uber-go/fx 装配所有依赖并管理生命周期。
//
// fx.Run() 会:
// 1. 按 fx.Supply/Provide 构建依赖图
// 2. 执行所有 fx.Invoke迁移、路由注册、服务器/任务启动)
// 3. 监听 SIGINT/SIGTERM 信号
// 4. 按依赖逆序执行所有 OnStop 钩子(优雅关闭)
func main() {
// 加载配置(唯一的全局入口,配置本身是无状态的纯数据)
cfg, err := config.Load()
if err != nil {
log.Fatalf("配置加载失败: %v", err)
}
// 创建并运行 fx 应用
fx.New(app.Module(cfg)).Run()
}