74 Star 631 Fork 263

ThingsPanel/thingspanel-backend-community

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 1.10 KB
一键复制 编辑 原始数据 按行查看 历史
package main
import (
"fmt"
"os"
"project/internal/app"
"github.com/sirupsen/logrus"
)
// @title ThingsPanel API
// @version 1.0
// @description ThingsPanel API.
// @schemes http
// @host localhost:9999
// @BasePath
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name x-token
func main() {
// 使用Application结构体初始化
application, err := app.NewApplication(
// 基础配置
app.WithProductionConfig(),
app.WithRsaDecrypt("./configs/rsa_key/private_key.pem"),
app.WithLogger(),
app.WithDatabase(),
app.WithRedis(),
// 服务
app.WithHTTPService(),
app.WithGRPCService(),
app.WithMQTTService(),
app.WithCronService(),
)
if err != nil {
fmt.Fprintf(os.Stderr, "应用初始化失败: %v\n", err)
os.Exit(1)
}
// 启动所有服务
if err := application.Start(); err != nil {
logrus.Fatalf("启动服务失败: %v", err)
}
// 等待服务运行并处理退出
application.Wait()
// 应用关闭时自动调用 Shutdown 方法清理资源
defer application.Shutdown()
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/ThingsPanel/thingspanel-backend-community.git
git@gitee.com:ThingsPanel/thingspanel-backend-community.git
ThingsPanel
thingspanel-backend-community
thingspanel-backend-community
main

搜索帮助