You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
877 B

  1. package main
  2. import (
  3. "gin-vue-admin/core"
  4. "gin-vue-admin/global"
  5. "gin-vue-admin/init"
  6. "gin-vue-admin/init/qmlog"
  7. "os"
  8. //"runtime"
  9. )
  10. // @title Swagger Example API
  11. // @version 0.0.1
  12. // @description This is a sample Server pets
  13. // @securityDefinitions.apikey ApiKeyAuth
  14. // @in header
  15. // @name x-token
  16. // @BasePath /
  17. var (
  18. mysqlHost = os.Getenv("MYSQLHOST")
  19. mysqlPort = os.Getenv("MYSQLPORT")
  20. )
  21. func main() {
  22. if err := qmlog.NewLogger(); err != nil {
  23. panic(err)
  24. }
  25. // 可以通过环境变量来覆盖配置值
  26. // 未设定有效的环境变量时,使用配置值
  27. mysqlConfig := init.GinVueAdminconfig.MysqlAdmin
  28. // 链接初始化数据库
  29. init.RegisterMysql(mysqlConfig) // 链接初始化数据库
  30. // 注册数据库表
  31. init.RegisterTable(global.GVA_DB)
  32. // 程序结束前关闭数据库链接
  33. defer global.GVA_DB.Close()
  34. core.RunWindowsServer()
  35. }