63 lines
1.5 KiB
Go
63 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"rocommon"
|
|
"rocommon/service"
|
|
_ "rocommon/socket"
|
|
_ "rocommon/socket/http"
|
|
_ "rocommon/socket/tcp"
|
|
authModel "roserver/auth/model"
|
|
"roserver/baseserver"
|
|
"roserver/baseserver/model"
|
|
"runtime"
|
|
"strconv"
|
|
"syscall"
|
|
)
|
|
|
|
func main() {
|
|
//记录gate pid用来做关闭操作
|
|
sysType := runtime.GOOS
|
|
if sysType != "windows" {
|
|
if pid := syscall.Getpid(); pid != 1 {
|
|
fileName := "auth_server.pid" + strconv.Itoa(pid)
|
|
ioutil.WriteFile(fileName, []byte(strconv.Itoa(pid)), 0777)
|
|
defer os.Remove(fileName)
|
|
}
|
|
}
|
|
|
|
//prof := profile.Start(profile.CPUProfile, profile.ProfilePath("./pprof/auth.pprof"), profile.NoShutdownHook)
|
|
|
|
baseserver.Init(model.SERVICE_NODE_TYPE_AUTH_STR, nil, &authModel.AuthUpdate{})
|
|
//baseserver.Init(model.SERVICE_NODE_TYPE_AUTH_STR, nil, nil)
|
|
|
|
//先建立服务器对应的连接,再监听客户端
|
|
sConfig := service.GetServiceConfig()
|
|
|
|
//创建服务器之间的监听
|
|
var acceNode rocommon.ServerNode = nil
|
|
if sConfig.Node.Addr != "" {
|
|
acceNode = baseserver.CreateAcceptor(baseserver.ServiceParam{
|
|
ServiceType: "tcpAcceptor",
|
|
ServiceName: model.SERVICE_NODE_TYPE_AUTH_STR,
|
|
ProcName: "auth.backend",
|
|
LisAddr: sConfig.Node.Addr,
|
|
}, sConfig)
|
|
}
|
|
|
|
//sdk http
|
|
authModel.SetHttpNodeParam(&baseserver.ServiceParam{
|
|
ServiceType: "httpConnector",
|
|
ServiceName: "game",
|
|
//LisAddr: "serverlist.wtgame.cn:8088",
|
|
//LisAddr: sConfig.Node.ServerList,
|
|
})
|
|
|
|
baseserver.Wait()
|
|
|
|
//prof.Stop()
|
|
|
|
baseserver.Exit(acceNode)
|
|
}
|