RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Get server type in boostrap (#21204)
Jin Haif70067992854
diff --git a/cmd/ragflow_server.go b/cmd/ragflow_server.goindex a3caba239b..c8510f087b 100644--- a/cmd/ragflow_server.go+++ b/cmd/ragflow_server.go@@ -341,10 +341,12 @@ func main() {os.Exit(1)}+ serverType := bootstrap.GetServerType(arguments)+// Temporary logger name (pre-config): explicit --name wins, else// "<mode>_server". The final name (with the resolved port for api/admin)// is derived below after the configuration is loaded.- serverName := bootstrap.TempServerName(*arguments.Mode, arguments.Name)+ serverName := bootstrap.TempServerName(serverType, arguments.Name)logLevel := bootstrap.SelectedLogLevel(arguments, "")if higherThanInfo := common.LogLevelHigherThanInfo(logLevel); higherThanInfo {@@ -390,8 +392,8 @@ func main() {// dropped: ResolveServerName resolves them to "<mode>_server", matching the// original no-name behavior.var resolvedPort int- switch *arguments.Mode {- case "api":+ switch serverType {+ case common.ServerTypeAPI:port, portErr := globalConfig.ResolvePort(globalConfig.GetAPIServerConfig().HTTPPort, arguments.Port)if portErr != nil {fmt.Printf("Failed to resolve API server port: %v\n", portErr)@@ -399,7 +401,7 @@ func main() {}globalConfig.SetAPIServerHTTPPort(port)resolvedPort = port- case "admin":+ case common.ServerTypeAdmin:port, portErr := globalConfig.ResolvePort(globalConfig.GetAdminServerConfig().HTTPPort, arguments.Port)if portErr != nil {fmt.Printf("Failed to resolve admin server port: %v\n", portErr)@@ -407,11 +409,10 @@ func main() {}globalConfig.SetAdminHTTPPort(port)resolvedPort = port- case "ingestor", "syncer", "deepdoc", "migrate":+ case common.ServerTypeIngestion, common.ServerTypeFileSyncer, common.ServerTypeDeepDocGPU, common.ServerTypeDeepDocAscend, common.ServerTypeDeepDocCPU, common.ServerTypeMigrate:// No port embedding; the final name is derived below.default:- err = errors.New(*arguments.Mode)- common.Error("invalid server mode", err)+ common.Error(fmt.Sprintf("invalid server mode: %v", serverType), nil)os.Exit(1)}@@ -432,8 +433,8 @@ func main() {// logger exists: its registration lines (and the Fatal abort on a missing// backend) must land in the run's log file, not in the pre-config// stdout-only window.- switch *arguments.Mode {- case "api", "ingestor":+ switch serverType {+ case common.ServerTypeAPI, common.ServerTypeIngestion:if err = deepdocpkg.RegisterNativeDeepDoc(arguments); err != nil {common.Error("Failed to register in-process DeepDoc backend", err)os.Exit(1)@@ -442,7 +443,7 @@ func main() {}// Print all configuration settings- common.Info(fmt.Sprintf("Starting %s server: %s, mode: %s", *arguments.Mode, serverName, globalConfig.GetMode()))+ common.Info(fmt.Sprintf("Starting %v server: %s, mode: %s", serverType, serverName, globalConfig.GetMode()))server.PrintAll()// Start pprof server if requested@@ -459,7 +460,7 @@ func main() {// downgrade check nor any of the engines started below, so it can run// before any server mode boots (see docker/entrypoint.sh and// docker/launch_backend_service.sh).- migrate := *arguments.Mode == "migrate"+ migrate := serverType == common.ServerTypeMigrateif migrate {common.Info("Running database migrations")}@@ -512,34 +513,34 @@ func main() {arguments.Name = &serverName}- switch *arguments.Mode {- case "api":+ switch serverType {+ case common.ServerTypeAPI:if err = apipkg.Run(ctx, serverName, arguments); err != nil {fmt.Printf("Failed to start API server: %v\n", err)os.Exit(1)}- case "admin":+ case common.ServerTypeAdmin:if err = admin.Run(ctx, serverName, arguments); err != nil {fmt.Printf("Failed to start ADMIN server: %v\n", err)os.Exit(1)}- case "ingestor":+ case common.ServerTypeIngestion:if err = ingestorpkg.Run(ctx, cancel, serverName, arguments); err != nil {fmt.Printf("Failed to start INGESTION worker: %v\n", err)os.Exit(1)}- case "syncer":+ case common.ServerTypeFileSyncer:if err = syncerpkg.Run(ctx, cancel, serverName, arguments); err != nil {fmt.Printf("Failed to start SYNCER: %v\n", err)os.Exit(1)}- case "deepdoc":+ case common.ServerTypeDeepDocGPU, common.ServerTypeDeepDocCPU:if err = runDeepDoc(ctx, serverName, arguments); err != nil {fmt.Printf("Failed to start DEEPDOC: %v\n", err)os.Exit(1)}default:- fmt.Printf("Invalid server mode: %s\n", *arguments.Mode)+ fmt.Printf("Invalid server mode: %v\n", serverType)os.Exit(1)}}diff --git a/internal/common/status_message.go b/internal/common/status_message.goindex d350af2a08..5c6a3b8a6e 100644--- a/internal/common/status_message.go+++ b/internal/common/status_message.go@@ -31,11 +31,15 @@ const (type ServerType stringconst (- ServerTypeAPI ServerType = "api_server" // API server- ServerTypeIngestion ServerType = "ingestor" // Ingestion server- ServerTypeFileSyncer ServerType = "file_syncer" // File syncer server- ServerTypeDeepDocGPU ServerType = "deep_doc_gpu" // DeepDoc GPU server- ServerTypeDeepDocCPU ServerType = "deep_doc_cpu" // DeepDoc CPU server+ ServerTypeAdmin ServerType = "admin" // Admin server+ ServerTypeAPI ServerType = "api" // API server+ ServerTypeIngestion ServerType = "ingestor" // Ingestion server+ ServerTypeFileSyncer ServerType = "syncer" // File syncer server+ ServerTypeDeepDocGPU ServerType = "deepdoc_gpu" // DeepDoc GPU server+ ServerTypeDeepDocCPU ServerType = "deepdoc_cpu" // DeepDoc CPU server+ ServerTypeDeepDocAscend ServerType = "deepdoc_ascend" // DeepDoc Ascend server+ ServerTypeMigrate ServerType = "migrate" // Migrate server+ ServerTypeUnknown ServerType = "unknown" // Unknown server)type BaseMessage struct {diff --git a/internal/server/bootstrap/bootstrap.go b/internal/server/bootstrap/bootstrap.goindex 59ba902f1e..f251f0745a 100644--- a/internal/server/bootstrap/bootstrap.go+++ b/internal/server/bootstrap/bootstrap.go@@ -20,7 +20,10 @@// makes the naming rules unit-testable without booting any subsystem.package bootstrap-import "fmt"+import (+ "fmt"+ "ragflow/internal/common"+)// TempServerName returns the placeholder server name used for the temporary,// stdout-only logger that exists before the configuration is loaded. An@@ -30,11 +33,11 @@ import "fmt"// This is intentionally distinct from ResolveServerName: the final name for// api/admin additionally embeds the resolved HTTP port, which is only known// after the configuration is initialized.-func TempServerName(mode string, nameFlag *string) string {+func TempServerName(serverType common.ServerType, nameFlag *string) string {if nameFlag != nil {return *nameFlag}- return mode + "_server"+ return string(serverType) + "_server"}// ResolveServerName derives the final server name for a mode, preserving the@@ -70,3 +73,22 @@ func ResolveServerName(mode string, nameFlag *string, port int) (string, error)return "", fmt.Errorf("unsupported server mode %q", mode)}}++func GetServerType(args *ServerArgs) common.ServerType {+ switch *args.Mode {+ case "api":+ return common.ServerTypeAPI+ case "admin":+ return common.ServerTypeAdmin+ case "ingestor":+ return common.ServerTypeIngestion+ case "syncer":+ return common.ServerTypeFileSyncer+ case "deepdoc":+ return common.ServerTypeDeepDocCPU+ case "migrate":+ return common.ServerTypeMigrate+ default:+ return common.ServerTypeUnknown+ }+}diff --git a/internal/server/bootstrap/bootstrap_test.go b/internal/server/bootstrap/bootstrap_test.goindex 5dee46a838..5d0eac8a72 100644--- a/internal/server/bootstrap/bootstrap_test.go+++ b/internal/server/bootstrap/bootstrap_test.go@@ -17,6 +17,7 @@package bootstrapimport (+ "ragflow/internal/common""strings""testing")@@ -140,10 +141,10 @@ func TestTempServerName(t *testing.T) {if got := TempServerName("api", strPtr("named")); got != "named" {t.Errorf("TempServerName(api, named) = %q, want named", got)}- for _, mode := range []string{"api", "admin", "ingestor", "syncer", "deepdoc", "migrate"} {- got := TempServerName(mode, nil)- if want := mode + "_server"; got != want {- t.Errorf("TempServerName(%q, nil) = %q, want %q", mode, got, want)+ for _, serverType := range []common.ServerType{common.ServerTypeAPI, common.ServerTypeAdmin, common.ServerTypeIngestion, common.ServerTypeFileSyncer, common.ServerTypeDeepDocCPU, common.ServerTypeDeepDocGPU, common.ServerTypeDeepDocAscend, common.ServerTypeMigrate} {+ got := TempServerName(serverType, nil)+ if want := string(serverType) + "_server"; got != want {+ t.Errorf("TempServerName(%q, nil) = %q, want %q", serverType, got, want)}}// Empty-name override is honored as empty (non-nil pointer wins).