main.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package main
  2. import (
  3. _ "go.uber.org/automaxprocs"
  4. "go.uber.org/zap"
  5. "server/core"
  6. "server/global"
  7. "server/initialize"
  8. )
  9. //go:generate go env -w GO111MODULE=on
  10. //go:generate go env -w GOPROXY=https://goproxy.cn,direct
  11. //go:generate go mod tidy
  12. //go:generate go mod download
  13. // @title Gin-Vue-Admin Swagger API接口文档
  14. // @version v2.6.3
  15. // @description 使用gin+vue进行极速开发的全栈开发基础平台
  16. // @securityDefinitions.apikey ApiKeyAuth
  17. // @in header
  18. // @name x-token
  19. // @BasePath /
  20. // InitBackend initializes the Go backend (Viper, Zap, GORM, Gin) and starts the
  21. // HTTP server in a background goroutine. It does not block. Call this before
  22. // running the Wails application.
  23. func InitBackend() {
  24. global.GVA_VP = core.Viper()
  25. initialize.OtherInit()
  26. global.GVA_LOG = core.Zap()
  27. zap.ReplaceGlobals(global.GVA_LOG)
  28. global.GVA_DB = initialize.Gorm()
  29. initialize.Timer()
  30. initialize.DBList()
  31. if global.GVA_DB != nil {
  32. initialize.RegisterTables()
  33. db, _ := global.GVA_DB.DB()
  34. defer db.Close()
  35. }
  36. initialize.InitUHFDevices()
  37. go core.RunWindowsServer()
  38. }
  39. // main is retained for standalone (non-Wails) usage.
  40. func main() {
  41. InitBackend()
  42. // Block forever when running standalone.
  43. select {}
  44. }