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.

49 lines
1.5 KiB

  1. package main
  2. import (
  3. "fmt"
  4. "gin-vue-admin/config"
  5. "gin-vue-admin/init/initRedis"
  6. "gin-vue-admin/init/initRouter"
  7. "gin-vue-admin/init/qmlog"
  8. "gin-vue-admin/init/qmsql"
  9. "gin-vue-admin/init/registTable"
  10. "net/http"
  11. "time"
  12. )
  13. // @title Swagger Example API
  14. // @version 0.0.1
  15. // @description This is a sample Server pets
  16. // @securityDefinitions.apikey ApiKeyAuth
  17. // @in header
  18. // @name x-token
  19. // @BasePath /
  20. func main() {
  21. qmlog.InitLog() // 初始化日志
  22. db := qmsql.InitMysql(config.GinVueAdminconfig.MysqlAdmin) // 链接初始化数据库
  23. if config.GinVueAdminconfig.System.UseMultipoint {
  24. _ = initRedis.InitRedis() // 初始化redis服务
  25. }
  26. registTable.RegistTable(db) //注册数据库表
  27. defer qmsql.DEFAULTDB.Close() // 程序结束前关闭数据库链接
  28. Router := initRouter.InitRouter() //注册路由
  29. qmlog.QMLog.Info("服务器开启") // 日志测试代码
  30. //Router.RunTLS(":443","ssl.pem", "ssl.key") // https支持 需要添加中间件
  31. s := &http.Server{
  32. Addr: ":8888",
  33. Handler: Router,
  34. ReadTimeout: 10 * time.Second,
  35. WriteTimeout: 10 * time.Second,
  36. MaxHeaderBytes: 1 << 20,
  37. }
  38. time.Sleep(10 * time.Microsecond)
  39. fmt.Printf(`欢迎使用 Gin-Vue-Admin
  40. 作者奇淼 And Spike666
  41. 微信shouzi_1994
  42. 默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
  43. 默认前端文件运行地址:http://127.0.0.1:8080
  44. `, s.Addr)
  45. _ = s.ListenAndServe()
  46. }