Browse Source

修复Windows下编译endless失败问题

main
徐志伟 4 years ago
parent
commit
63f2886de6
  1. 21
      server/core/server.go
  2. 17
      server/core/server_other.go
  3. 19
      server/core/server_win.go

21
server/core/server.go

@ -4,10 +4,6 @@ import (
"fmt"
"gin-vue-admin/global"
"gin-vue-admin/initialize"
"github.com/fvbock/endless"
"github.com/gin-gonic/gin"
"net/http"
"runtime"
"time"
)
@ -15,23 +11,6 @@ type server interface {
ListenAndServe() error
}
func initServer(address string, router *gin.Engine) server {
if runtime.GOOS == "windows" {
return &http.Server{
Addr: address,
Handler: router,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
}
s := endless.NewServer(address, router)
s.ReadHeaderTimeout = 10 * time.Millisecond
s.WriteTimeout = 10 * time.Second
s.MaxHeaderBytes = 1 << 20
return s
}
func RunWindowsServer() {
if global.GVA_CONFIG.System.UseMultipoint {
// 初始化redis服务

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,
}
}
Loading…
Cancel
Save