新增:支持配置文件设置服务参数
git-svn-id: svn://47.119.165.148/zhub@73 e63fbceb-bcc3-4977-ac22-735b83d8d0f4
This commit is contained in:
37
app.go
Normal file
37
app.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"zhub/cli"
|
||||
"zhub/conf"
|
||||
"zhub/zsub"
|
||||
)
|
||||
|
||||
func main() {
|
||||
server := true
|
||||
confPath := "app.conf"
|
||||
addr := ""
|
||||
|
||||
for _, arg := range os.Args[1:] {
|
||||
if strings.EqualFold(arg, "cli") {
|
||||
server = false
|
||||
} else if strings.Index(arg, "-d=") == 0 {
|
||||
addr = arg[3:]
|
||||
} else if strings.Index(arg, "-c=") == 0 {
|
||||
confPath = arg[3:]
|
||||
}
|
||||
}
|
||||
|
||||
if server {
|
||||
conf.Load(confPath)
|
||||
if len(addr) == 0 {
|
||||
addr = conf.GetStr("service.zhub.servers", "127.0.0.1:1216")
|
||||
}
|
||||
// 服务进程启动
|
||||
zsub.ServerStart(addr)
|
||||
} else {
|
||||
cli.ClientRun(addr)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user