未验证 提交 90f53375 编写于 作者: 徐志伟 提交者: GitHub

非Windows操作系统使用endless启动服务

上级 178b028a
......@@ -4,10 +4,34 @@ import (
"fmt"
"gin-vue-admin/global"
"gin-vue-admin/initialize"
"github.com/fvbock/endless"
"github.com/gin-gonic/gin"
"net/http"
"runtime"
"time"
)
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服务
......@@ -20,13 +44,7 @@ func RunWindowsServer() {
// end 插件描述
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
time.Sleep(10 * time.Microsecond)
......@@ -35,6 +53,6 @@ func RunWindowsServer() {
fmt.Printf(`欢迎使用 Gin-Vue-Admin
默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
默认前端文件运行地址:http://127.0.0.1:8080
`, s.Addr)
`, address)
global.GVA_LOG.Error(s.ListenAndServe())
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册