server.go 996 字节
Newer Older
Mr.奇淼('s avatar
Mr.奇淼( 已提交
1
package core
Mr.奇淼('s avatar
Mr.奇淼( 已提交
2 3 4

import (
	"fmt"
Mr.奇淼('s avatar
Mr.奇淼( 已提交
5
	"gin-vue-admin/global"
6
	"gin-vue-admin/initialize"
Mr.奇淼('s avatar
Mr.奇淼( 已提交
7 8 9 10
	"net/http"
	"time"
)

Mr.奇淼('s avatar
Mr.奇淼( 已提交
11 12 13
func RunWindowsServer() {
	if global.GVA_CONFIG.System.UseMultipoint {
		// 初始化redis服务
14
		initialize.Redis()
Mr.奇淼('s avatar
Mr.奇淼( 已提交
15
	}
16
	Router := initialize.Routers()
Mr.奇淼('s avatar
Mr.奇淼( 已提交
17
	Router.Static("/form-generator", "./resource/page")
18

Mr.奇淼('s avatar
Mr.奇淼( 已提交
19
	InstallPlugs(Router)
20
	// end 插件描述
Mr.奇淼('s avatar
Mr.奇淼( 已提交
21

Mr.奇淼('s avatar
Mr.奇淼( 已提交
22
	address := fmt.Sprintf(":%d", global.GVA_CONFIG.System.Addr)
Mr.奇淼('s avatar
Mr.奇淼( 已提交
23
	s := &http.Server{
G
Granty1 已提交
24
		Addr:           address,
Mr.奇淼('s avatar
Mr.奇淼( 已提交
25 26 27 28 29
		Handler:        Router,
		ReadTimeout:    10 * time.Second,
		WriteTimeout:   10 * time.Second,
		MaxHeaderBytes: 1 << 20,
	}
30 31
	// 保证文本顺序输出
	// In order to ensure that the text order output can be deleted
Mr.奇淼('s avatar
Mr.奇淼( 已提交
32
	time.Sleep(10 * time.Microsecond)
33
	global.GVA_LOG.Debug("server run success on ", address)
G
Granty1 已提交
34

Mr.奇淼('s avatar
Mr.奇淼( 已提交
35 36 37 38
	fmt.Printf(`欢迎使用 Gin-Vue-Admin
	默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
	默认前端文件运行地址:http://127.0.0.1:8080
`, s.Addr)
39
	global.GVA_LOG.Error(s.ListenAndServe())
Mr.奇淼('s avatar
Mr.奇淼( 已提交
40
}