feat: add team registration execution API endpoint.

This commit is contained in:
2026-02-01 07:00:22 +08:00
parent eb74a1cbab
commit d7cfa00349

View File

@@ -431,16 +431,21 @@ func findTeamRegExecutable() string {
// 获取当前工作目录 // 获取当前工作目录
cwd, _ := os.Getwd() cwd, _ := os.Getwd()
// 获取可执行文件所在目录 // 获取可执行文件的真实路径(解析符号链接)
execPath, _ := os.Executable() execPath, _ := os.Executable()
realExecPath, err := filepath.EvalSymlinks(execPath)
if err == nil {
execPath = realExecPath
}
execDir := filepath.Dir(execPath) execDir := filepath.Dir(execPath)
// 可能的路径(按优先级排序) // 可能的路径(按优先级排序)
paths := []string{ paths := []string{
execDir, // 可执行文件所在目录最可靠team-reg 应与后端在同一目录)
cwd, // 当前工作目录 cwd, // 当前工作目录
filepath.Join(cwd, "backend"), // cwd/backend filepath.Join(cwd, "backend"), // cwd/backend
execDir, // 可执行文件所在目录
filepath.Join(execDir, ".."), // 可执行文件上级目录 filepath.Join(execDir, ".."), // 可执行文件上级目录
filepath.Join(execDir, "backend"), // execDir/backend
".", // 相对当前目录 ".", // 相对当前目录
"backend", // 相对 backend 目录 "backend", // 相对 backend 目录
"..", // 上级目录 "..", // 上级目录
@@ -451,6 +456,7 @@ func findTeamRegExecutable() string {
// 记录搜索过程 // 记录搜索过程
logger.Info(fmt.Sprintf("[TeamReg] 当前工作目录: %s", cwd), "", "team-reg") logger.Info(fmt.Sprintf("[TeamReg] 当前工作目录: %s", cwd), "", "team-reg")
logger.Info(fmt.Sprintf("[TeamReg] 可执行文件路径: %s", execPath), "", "team-reg")
logger.Info(fmt.Sprintf("[TeamReg] 可执行文件目录: %s", execDir), "", "team-reg") logger.Info(fmt.Sprintf("[TeamReg] 可执行文件目录: %s", execDir), "", "team-reg")
for _, basePath := range paths { for _, basePath := range paths {
@@ -465,11 +471,15 @@ func findTeamRegExecutable() string {
} }
} }
// 未找到,输出所有搜索过的路径 // 未找到,输出所有搜索过的路径到前端日志,方便排查
logger.Error("[TeamReg] team-reg 可执行文件未找到,已搜索以下路径:", "", "team-reg") addTeamRegLog("[错误] 已搜索以下路径均未找到 team-reg:")
addTeamRegLog(fmt.Sprintf(" 工作目录: %s", cwd))
addTeamRegLog(fmt.Sprintf(" 可执行文件目录: %s", execDir))
for _, basePath := range paths { for _, basePath := range paths {
absPath, _ := filepath.Abs(basePath) absPath, _ := filepath.Abs(basePath)
logger.Error(fmt.Sprintf(" - %s", absPath), "", "team-reg") for _, name := range names {
addTeamRegLog(fmt.Sprintf(" - %s", filepath.Join(absPath, name)))
}
} }
return "" return ""