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.

45 lines
1.3 KiB

  1. package core
  2. import (
  3. "fmt"
  4. "gin-vue-admin/global"
  5. "gin-vue-admin/initialize"
  6. "github.com/piexlmax/gvaplug"
  7. "net/http"
  8. "time"
  9. )
  10. func RunWindowsServer() {
  11. if global.GVA_CONFIG.System.UseMultipoint {
  12. // 初始化redis服务
  13. initialize.Redis()
  14. }
  15. Router := initialize.Routers()
  16. Router.Static("/form-generator", "./resource/page")
  17. // 插件安装 暂时只是后台功能 添加model 添加路由 添加对数据库的操作 详细插件测试模板可看https://github.com/piexlmax/gvaplug 此处不建议投入生产
  18. err := initialize.InstallPlug(global.GVA_DB, Router, gvaplug.GvaPlug{})
  19. if err != nil {
  20. panic(fmt.Sprintf("插件安装失败: %v", err))
  21. }
  22. // end 插件描述
  23. address := fmt.Sprintf(":%d", global.GVA_CONFIG.System.Addr)
  24. s := &http.Server{
  25. Addr: address,
  26. Handler: Router,
  27. ReadTimeout: 10 * time.Second,
  28. WriteTimeout: 10 * time.Second,
  29. MaxHeaderBytes: 1 << 20,
  30. }
  31. // 保证文本顺序输出
  32. // In order to ensure that the text order output can be deleted
  33. time.Sleep(10 * time.Microsecond)
  34. global.GVA_LOG.Debug("server run success on ", address)
  35. fmt.Printf(`欢迎使用 Gin-Vue-Admin
  36. 默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
  37. 默认前端文件运行地址:http://127.0.0.1:8080
  38. `, s.Addr)
  39. global.GVA_LOG.Error(s.ListenAndServe())
  40. }