package main import ( "go.uber.org/zap" "goiot-cronapi/common" "goiot-cronapi/global/orm" "goiot-cronapi/global/redis" "goiot-cronapi/pkg/logger" "goiot-cronapi/router" "goiot-pkg/tools" "net/http" ) // @title LiHua Cloud Platform Server Api // @version 1.0 // @description This is lihua cloud platform api func main() { engine := router.InitRouter() server := common.ConfigInfo.Server serverInfo := server.Host + ":" + server.Port logger.Info("Server Start Info: " + serverInfo) if err := engine.Run(serverInfo); err != nil && err != http.ErrServerClosed { logger.Fatal("Listen", zap.String("[FATAL]", err.Error())) } } func init() { var err error // 加载本地配置 err = common.LoadConfigInformation() if err != nil { return } // 加载Apollo配置 var apolloConf *tools.ApolloConfig apolloConf, err = common.LoadApolloConfig() if err != nil { return } orm.Eloquent = apolloConf.DB redis.Cacher = apolloConf.Redis // 日志初始化 logger.Init(&logger.Config{ Compress: common.ConfigInfo.Log.Compress == 1, ConsoleStdout: common.ConfigInfo.Log.ConsoleStdout == 1, FileStdout: common.ConfigInfo.Log.FileStdout == 1, Level: common.ConfigInfo.Log.Level, LocalTime: common.ConfigInfo.Log.LocalTime == 1, MaxAge: common.ConfigInfo.Log.MaxAge, MaxBackups: common.ConfigInfo.Log.MaxBackups, MaxSize: common.ConfigInfo.Log.MaxSize, Path: common.ConfigInfo.Log.Path, }) }