mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-29 04:08:12 +08:00
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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user