feat: add team registration execution API endpoint
This commit is contained in:
@@ -421,32 +421,50 @@ func findTeamRegExecutable() string {
|
||||
names = []string{"team-reg", "team-reg.exe"}
|
||||
}
|
||||
|
||||
// 可能的路径
|
||||
paths := []string{
|
||||
".", // 当前目录
|
||||
"..", // 上级目录
|
||||
"../", // 项目根目录
|
||||
filepath.Join("..", ".."), // 更上级
|
||||
}
|
||||
// 获取当前工作目录
|
||||
cwd, _ := os.Getwd()
|
||||
|
||||
// 获取可执行文件所在目录
|
||||
execDir, err := os.Executable()
|
||||
if err == nil {
|
||||
execDir = filepath.Dir(execDir)
|
||||
paths = append(paths, execDir, filepath.Join(execDir, ".."))
|
||||
execPath, _ := os.Executable()
|
||||
execDir := filepath.Dir(execPath)
|
||||
|
||||
// 可能的路径(按优先级排序)
|
||||
paths := []string{
|
||||
cwd, // 当前工作目录
|
||||
filepath.Join(cwd, "backend"), // cwd/backend
|
||||
execDir, // 可执行文件所在目录
|
||||
filepath.Join(execDir, ".."), // 可执行文件上级目录
|
||||
".", // 相对当前目录
|
||||
"backend", // 相对 backend 目录
|
||||
"..", // 上级目录
|
||||
filepath.Join("..", "backend"), // ../backend
|
||||
filepath.Join("..", ".."), // 更上级
|
||||
filepath.Join("..", "..", "backend"), // ../../backend
|
||||
}
|
||||
|
||||
// 记录搜索过程
|
||||
logger.Info(fmt.Sprintf("[TeamReg] 当前工作目录: %s", cwd), "", "team-reg")
|
||||
logger.Info(fmt.Sprintf("[TeamReg] 可执行文件目录: %s", execDir), "", "team-reg")
|
||||
|
||||
for _, basePath := range paths {
|
||||
for _, name := range names {
|
||||
fullPath := filepath.Join(basePath, name)
|
||||
if absPath, err := filepath.Abs(fullPath); err == nil {
|
||||
if _, err := os.Stat(absPath); err == nil {
|
||||
logger.Info(fmt.Sprintf("[TeamReg] 找到文件: %s", absPath), "", "team-reg")
|
||||
return absPath
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 未找到,输出所有搜索过的路径
|
||||
logger.Error("[TeamReg] team-reg 可执行文件未找到,已搜索以下路径:", "", "team-reg")
|
||||
for _, basePath := range paths {
|
||||
absPath, _ := filepath.Abs(basePath)
|
||||
logger.Error(fmt.Sprintf(" - %s", absPath), "", "team-reg")
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user