main.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package main
  2. import (
  3. _ "go.uber.org/automaxprocs"
  4. "go.uber.org/zap"
  5. "log"
  6. "server/service/admin"
  7. "server/utils/logger"
  8. "server/core"
  9. "server/global"
  10. "server/initialize"
  11. )
  12. //go:generate go env -w GO111MODULE=on
  13. //go:generate go env -w GOPROXY=https://goproxy.cn,direct
  14. //go:generate go mod tidy
  15. //go:generate go mod download
  16. // @title Gin-Vue-Admin Swagger API接口文档
  17. // @version v2.6.3
  18. // @description 使用gin+vue进行极速开发的全栈开发基础平台
  19. // @securityDefinitions.apikey ApiKeyAuth
  20. // @in header
  21. // @name x-token
  22. // @BasePath /
  23. func main() {
  24. global.GVA_VP = core.Viper() // 初始化Viper
  25. logPath := "./logs/app.log"
  26. if err := logger.Initialize(logPath); err != nil {
  27. log.Fatalf("Failed to initialize logger: %v", err)
  28. }
  29. initialize.OtherInit()
  30. global.GVA_LOG = core.Zap() // 初始化zap日志库
  31. zap.ReplaceGlobals(global.GVA_LOG)
  32. global.GVA_DB = initialize.Gorm() // gorm连接数据库
  33. initialize.Timer()
  34. initialize.DBList()
  35. admin.InitMqtt() //mqtt
  36. if global.GVA_DB != nil {
  37. initialize.RegisterTables() // 初始化表
  38. // 程序结束前关闭数据库链接
  39. db, _ := global.GVA_DB.DB()
  40. defer db.Close()
  41. }
  42. core.RunWindowsServer()
  43. }