|
@ -2,10 +2,11 @@ package utils |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"encoding/json" |
|
|
"encoding/json" |
|
|
"github.com/aceld/zinx/ziface" |
|
|
|
|
|
"github.com/aceld/zinx/zlog" |
|
|
|
|
|
"io/ioutil" |
|
|
"io/ioutil" |
|
|
"os" |
|
|
"os" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/aceld/zinx/ziface" |
|
|
|
|
|
"github.com/aceld/zinx/zlog" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
@ -16,9 +17,9 @@ type GlobalObj struct { |
|
|
/* |
|
|
/* |
|
|
Server |
|
|
Server |
|
|
*/ |
|
|
*/ |
|
|
TcpServer ziface.IServer //当前Zinx的全局Server对象
|
|
|
|
|
|
|
|
|
TCPServer ziface.IServer //当前Zinx的全局Server对象
|
|
|
Host string //当前服务器主机IP
|
|
|
Host string //当前服务器主机IP
|
|
|
TcpPort int //当前服务器主机监听端口号
|
|
|
|
|
|
|
|
|
TCPPort int //当前服务器主机监听端口号
|
|
|
Name string //当前服务器名称
|
|
|
Name string //当前服务器名称
|
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
@ -49,7 +50,7 @@ type GlobalObj struct { |
|
|
*/ |
|
|
*/ |
|
|
var GlobalObject *GlobalObj |
|
|
var GlobalObject *GlobalObj |
|
|
|
|
|
|
|
|
//判断一个文件是否存在
|
|
|
|
|
|
|
|
|
//PathExists 判断一个文件是否存在
|
|
|
func PathExists(path string) (bool, error) { |
|
|
func PathExists(path string) (bool, error) { |
|
|
_, err := os.Stat(path) |
|
|
_, err := os.Stat(path) |
|
|
if err == nil { |
|
|
if err == nil { |
|
@ -61,7 +62,7 @@ func PathExists(path string) (bool, error) { |
|
|
return false, err |
|
|
return false, err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//读取用户的配置文件
|
|
|
|
|
|
|
|
|
//Reload 读取用户的配置文件
|
|
|
func (g *GlobalObj) Reload() { |
|
|
func (g *GlobalObj) Reload() { |
|
|
|
|
|
|
|
|
if confFileExists, _ := PathExists(g.ConfFilePath); confFileExists != true { |
|
|
if confFileExists, _ := PathExists(g.ConfFilePath); confFileExists != true { |
|
@ -100,15 +101,15 @@ func init() { |
|
|
GlobalObject = &GlobalObj{ |
|
|
GlobalObject = &GlobalObj{ |
|
|
Name: "ZinxServerApp", |
|
|
Name: "ZinxServerApp", |
|
|
Version: "V0.11", |
|
|
Version: "V0.11", |
|
|
TcpPort: 8999, |
|
|
|
|
|
|
|
|
TCPPort: 8999, |
|
|
Host: "0.0.0.0", |
|
|
Host: "0.0.0.0", |
|
|
MaxConn: 12000, |
|
|
MaxConn: 12000, |
|
|
MaxPacketSize: 4096, |
|
|
MaxPacketSize: 4096, |
|
|
ConfFilePath: pwd+"/conf/zinx.json", |
|
|
|
|
|
|
|
|
ConfFilePath: pwd + "/conf/zinx.json", |
|
|
WorkerPoolSize: 10, |
|
|
WorkerPoolSize: 10, |
|
|
MaxWorkerTaskLen: 1024, |
|
|
MaxWorkerTaskLen: 1024, |
|
|
MaxMsgChanLen: 1024, |
|
|
MaxMsgChanLen: 1024, |
|
|
LogDir: pwd+"/log", |
|
|
|
|
|
|
|
|
LogDir: pwd + "/log", |
|
|
LogFile: "", |
|
|
LogFile: "", |
|
|
LogDebugClose: false, |
|
|
LogDebugClose: false, |
|
|
} |
|
|
} |
|
|