版本封存
This commit is contained in:
37
cmii-uav-watchdog-center/cmd/main.go
Normal file
37
cmii-uav-watchdog-center/cmd/main.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"cmii-uav-watchdog-center/config"
|
||||
"cmii-uav-watchdog-center/router"
|
||||
"cmii-uav-watchdog-common/wdd_log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 获取执行目录
|
||||
execDir, err := filepath.Abs(filepath.Dir(os.Args[0]))
|
||||
if err != nil {
|
||||
wdd_log.Fatal("获取执行目录失败: %v", err)
|
||||
}
|
||||
|
||||
// 配置文件路径
|
||||
configPath := filepath.Join(execDir, "config.json")
|
||||
|
||||
// 加载配置
|
||||
config, err := config.LoadConfig(configPath)
|
||||
if err != nil {
|
||||
wdd_log.Fatal("加载配置失败: %v", err)
|
||||
}
|
||||
|
||||
// 设置路由
|
||||
r := router.SetupRouter()
|
||||
|
||||
// 启动服务器
|
||||
port := config.Server.Port
|
||||
wdd_log.Info("服务器正在监听端口: %d", port)
|
||||
if err := r.Run(":" + strconv.Itoa(port)); err != nil {
|
||||
wdd_log.Error("启动服务器失败: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user