Skip to content

Commit 86ad612

Browse files
author
pixel
committed
Merge branches 'develop' and 'operation-record' of https://github.com/piexlmax/QMPlus into operation-record
2 parents df0312e + 92f82af commit 86ad612

File tree

4 files changed

+43
-9
lines changed

4 files changed

+43
-9
lines changed

server/core/server.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ import (
44
"fmt"
55
"gin-vue-admin/global"
66
"gin-vue-admin/initialize"
7-
"net/http"
87
"time"
98
)
109

10+
type server interface {
11+
ListenAndServe() error
12+
}
13+
1114
func RunWindowsServer() {
1215
if global.GVA_CONFIG.System.UseMultipoint {
1316
// 初始化redis服务
@@ -20,13 +23,7 @@ func RunWindowsServer() {
2023
// end 插件描述
2124

2225
address := fmt.Sprintf(":%d", global.GVA_CONFIG.System.Addr)
23-
s := &http.Server{
24-
Addr: address,
25-
Handler: Router,
26-
ReadTimeout: 10 * time.Second,
27-
WriteTimeout: 10 * time.Second,
28-
MaxHeaderBytes: 1 << 20,
29-
}
26+
s := initServer(address, Router)
3027
// 保证文本顺序输出
3128
// In order to ensure that the text order output can be deleted
3229
time.Sleep(10 * time.Microsecond)
@@ -35,6 +32,6 @@ func RunWindowsServer() {
3532
fmt.Printf(`欢迎使用 Gin-Vue-Admin
3633
默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
3734
默认前端文件运行地址:http://127.0.0.1:8080
38-
`, s.Addr)
35+
`, address)
3936
global.GVA_LOG.Error(s.ListenAndServe())
4037
}

server/core/server_other.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// +build !windows
2+
3+
package core
4+
5+
import (
6+
"github.com/fvbock/endless"
7+
"github.com/gin-gonic/gin"
8+
"time"
9+
)
10+
11+
func initServer(address string, router *gin.Engine) server {
12+
s := endless.NewServer(address, router)
13+
s.ReadHeaderTimeout = 10 * time.Millisecond
14+
s.WriteTimeout = 10 * time.Second
15+
s.MaxHeaderBytes = 1 << 20
16+
return s
17+
}

server/core/server_win.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// +build windows
2+
3+
package core
4+
5+
import (
6+
"github.com/gin-gonic/gin"
7+
"net/http"
8+
"time"
9+
)
10+
11+
func initServer(address string, router *gin.Engine) server {
12+
return &http.Server{
13+
Addr: address,
14+
Handler: router,
15+
ReadTimeout: 10 * time.Second,
16+
WriteTimeout: 10 * time.Second,
17+
MaxHeaderBytes: 1 << 20,
18+
}
19+
}

server/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require (
99
github.com/dgrijalva/jwt-go v3.2.0+incompatible
1010
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 // indirect
1111
github.com/fsnotify/fsnotify v1.4.9
12+
github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6
1213
github.com/gin-gonic/gin v1.6.3
1314
github.com/go-openapi/spec v0.19.7 // indirect
1415
github.com/go-openapi/swag v0.19.8 // indirect

0 commit comments

Comments
 (0)