修改:代码包结构

This commit is contained in:
2023-07-02 00:46:04 +08:00
parent 66321ce7a8
commit 913a531f30
8 changed files with 157 additions and 226 deletions

14
main.go
View File

@@ -5,7 +5,8 @@ import (
"log"
"zhub/cmd"
"zhub/internal/config"
"zhub/zsub"
"zhub/internal/monitor"
"zhub/internal/zsub"
)
func main() {
@@ -19,6 +20,15 @@ func main() {
addr := conf.Service.Addr // 获取服务地址
config.InitLog(conf.Log) // 初始化日志配置
{
/*
使用环境变量覆盖 配置文件参数 TODO
port, err := strconv.Atoi(os.Getenv("PORT"))
if err != nil {
port = 6066
}*/
}
if rcmd != "" { // 如果指定了客户端命令
auth := "" // 认证信息
for key, value := range conf.Auth { // 遍历找到一个认证信息
@@ -42,7 +52,7 @@ func main() {
if isCliMode {
cmd.ClientRun(addr) // 客户端运行
} else {
go zsub.StartWatch() // 启动监控协程
go monitor.StartWatch() // 启动监控协程
zsub.StartServer(addr, conf) // 启动服务进程
}
}