Browse Source

Merge branches 'develop' and 'operation-record' of https://github.com/piexlmax/QMPlus into operation-record

main
pixel 4 years ago
parent
commit
b214d875b7
  1. 15
      server/core/server.go
  2. 17
      server/core/server_other.go
  3. 19
      server/core/server_win.go
  4. 1
      server/go.mod

15
server/core/server.go

@ -4,10 +4,13 @@ import (
"fmt" "fmt"
"gin-vue-admin/global" "gin-vue-admin/global"
"gin-vue-admin/initialize" "gin-vue-admin/initialize"
"net/http"
"time" "time"
) )
type server interface {
ListenAndServe() error
}
func RunWindowsServer() { func RunWindowsServer() {
if global.GVA_CONFIG.System.UseMultipoint { if global.GVA_CONFIG.System.UseMultipoint {
// 初始化redis服务 // 初始化redis服务
@ -20,13 +23,7 @@ func RunWindowsServer() {
// end 插件描述 // end 插件描述
address := fmt.Sprintf(":%d", global.GVA_CONFIG.System.Addr) address := fmt.Sprintf(":%d", global.GVA_CONFIG.System.Addr)
s := &http.Server{
Addr: address,
Handler: Router,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
s := initServer(address, Router)
// 保证文本顺序输出 // 保证文本顺序输出
// In order to ensure that the text order output can be deleted // In order to ensure that the text order output can be deleted
time.Sleep(10 * time.Microsecond) time.Sleep(10 * time.Microsecond)
@ -35,6 +32,6 @@ func RunWindowsServer() {
fmt.Printf(`欢迎使用 Gin-Vue-Admin fmt.Printf(`欢迎使用 Gin-Vue-Admin
默认自动化文档地址:http://127.0.0.1%s/swagger/index.html 默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
默认前端文件运行地址:http://127.0.0.1:8080 默认前端文件运行地址:http://127.0.0.1:8080
`, s.Addr)
`, address)
global.GVA_LOG.Error(s.ListenAndServe()) global.GVA_LOG.Error(s.ListenAndServe())
} }

17
server/core/server_other.go

@ -0,0 +1,17 @@
// +build !windows
package core
import (
"github.com/fvbock/endless"
"github.com/gin-gonic/gin"
"time"
)
func initServer(address string, router *gin.Engine) server {
s := endless.NewServer(address, router)
s.ReadHeaderTimeout = 10 * time.Millisecond
s.WriteTimeout = 10 * time.Second
s.MaxHeaderBytes = 1 << 20
return s
}

19
server/core/server_win.go

@ -0,0 +1,19 @@
// +build windows
package core
import (
"github.com/gin-gonic/gin"
"net/http"
"time"
)
func initServer(address string, router *gin.Engine) server {
return &http.Server{
Addr: address,
Handler: router,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
}

1
server/go.mod

@ -9,6 +9,7 @@ require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 // indirect github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 // indirect
github.com/fsnotify/fsnotify v1.4.9 github.com/fsnotify/fsnotify v1.4.9
github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6
github.com/gin-gonic/gin v1.6.3 github.com/gin-gonic/gin v1.6.3
github.com/go-openapi/spec v0.19.7 // indirect github.com/go-openapi/spec v0.19.7 // indirect
github.com/go-openapi/swag v0.19.8 // indirect github.com/go-openapi/swag v0.19.8 // indirect

Loading…
Cancel
Save