Go: unify three services into one binary (#16462)

### Summary

Plan to start api_server, admin_server and ingestor in one binary:
- ./ragflow_main --admin
- ./ragflow_main --api
- ./ragflow_main --ingestor

---------

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-07-02 21:21:10 +08:00
committed by GitHub
parent 32c5cb16e9
commit 7d64a78f83
19 changed files with 761 additions and 770 deletions

View File

@@ -17,6 +17,7 @@ limitations under the License.
package utility
import (
"fmt"
"os"
"path/filepath"
"runtime"
@@ -58,3 +59,53 @@ func GetProjectRoot() string {
}
return filepath.Dir(filepath.Dir(exe))
}
func FindConfFileInProject(fileName string) (*string, error) {
var filePath string
if projDir := os.Getenv("RAG_PROJECT_BASE"); projDir != "" {
filePath = filepath.Join(projDir, "conf", fileName)
if _, err := os.Stat(filePath); err == nil {
return &filePath, nil
}
}
if projDir := os.Getenv("RAG_DEPLOY_BASE"); projDir != "" {
filePath = filepath.Join(projDir, "conf", fileName)
if _, err := os.Stat(filePath); err == nil {
return &filePath, nil
}
}
exeFilePath, err := os.Executable()
if err == nil {
projDir := filepath.Dir(filepath.Dir(exeFilePath))
filePath = filepath.Join(projDir, "conf", fileName)
if _, err = os.Stat(filePath); err == nil {
return &filePath, nil
}
}
_, curFile, _, _ := runtime.Caller(0)
dir := filepath.Dir(curFile)
for {
if _, err = os.Stat(filepath.Join(dir, "go.mod")); err == nil {
filePath = filepath.Join(dir, "conf", fileName)
if _, err = os.Stat(filePath); err == nil {
return &filePath, nil
}
return nil, fmt.Errorf("conf file %s not found in %s", fileName, dir)
}
parent := filepath.Dir(dir)
if parent == dir {
projDir := filepath.Dir(filepath.Dir(filepath.Dir(filepath.Dir(curFile))))
filePath = filepath.Join(projDir, "conf", fileName)
if _, err = os.Stat(filePath); err == nil {
return &filePath, nil
}
return nil, fmt.Errorf("conf file %s not found in %s", fileName, projDir)
}
dir = parent
}
}