42 lines
888 B
Go
42 lines
888 B
Go
package core
|
|
|
|
import (
|
|
"fmt"
|
|
"git.echol.cn/loser/lckt/global"
|
|
"git.echol.cn/loser/lckt/initialize"
|
|
"git.echol.cn/loser/lckt/service/system"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
type server interface {
|
|
ListenAndServe() error
|
|
}
|
|
|
|
func RunWindowsServer() {
|
|
if global.GVA_CONFIG.System.UseMultipoint || global.GVA_CONFIG.System.UseRedis {
|
|
// 初始化redis服务
|
|
initialize.Redis()
|
|
initialize.RedisList()
|
|
}
|
|
|
|
if global.GVA_CONFIG.System.UseMongo {
|
|
err := initialize.Mongo.Initialization()
|
|
if err != nil {
|
|
zap.L().Error(fmt.Sprintf("%+v", err))
|
|
}
|
|
}
|
|
// 从db加载jwt数据
|
|
if global.GVA_DB != nil {
|
|
system.LoadAll()
|
|
}
|
|
|
|
Router := initialize.Routers()
|
|
|
|
address := fmt.Sprintf(":%d", global.GVA_CONFIG.System.Addr)
|
|
s := initServer(address, Router)
|
|
|
|
global.GVA_LOG.Info("server run success on ", zap.String("address", address))
|
|
|
|
global.GVA_LOG.Error(s.ListenAndServe().Error())
|
|
}
|