Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

refactor deepdoc backend register (#19224)

xugangqiang20b6075d9259
diff --git a/cmd/ragflow_server.go b/cmd/ragflow_server.go
index 1cd60c8074..64dcb6316a 100644
--- a/cmd/ragflow_server.go
+++ b/cmd/ragflow_server.go
@@ -63,7 +63,6 @@ import (
"ragflow/internal/engine/redis"
_ "ragflow/internal/ingestion/wire"
"ragflow/internal/server"
- "ragflow/internal/servermode"
"ragflow/internal/utility"
)
@@ -283,24 +282,12 @@ func main() {
os.Exit(1)
}
- // Register the in-process (Go) DeepDoc backend for the modes that run the
- // document parsing pipeline. This server is built with -tags cgo and links
- // ONNX Runtime statically (libonnxruntime.a, resolved via dlopen(NULL)),
- // so the in-process backend is the production backend with no external
- // DeepDoc HTTP service. Fail fast if it cannot serve — but only for modes
- // that actually need it: "api" parses in-process (dataflow debug and other
- // routes) and "ingestor" runs the ingestion pipeline. "admin"/"syncer"
- // never instantiate the analyzer, so they must not fail-fast when ORT and
- // models are absent on their node.
- if servermode.NeedsDeepDoc(*arguments.mode) {
- registerNativeDeepDoc()
- }
-
globalConfig := server.GetConfig()
// override default port if provided
switch *arguments.mode {
case "api":
+ registerNativeDeepDoc()
apiServerConfig := globalConfig.GetAPIServerConfig()
port := apiServerConfig.HTTPPort
if arguments.port != nil {
@@ -321,6 +308,7 @@ func main() {
serverName = fmt.Sprintf("admin_server_%d", port)
}
case "ingestor":
+ registerNativeDeepDoc()
if serverName == "" {
uuid := utility.GenerateUUID()
serverName = fmt.Sprintf("ingestor_server_%s", uuid)
diff --git a/internal/servermode/servermode.go b/internal/servermode/servermode.go
deleted file mode 100644
index 087cb7d6e9..0000000000
--- a/internal/servermode/servermode.go
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-//
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-// Package servermode holds server-mode policy decisions that do not depend on
-// the cgo-linked DeepDoc native backend, so they stay unit-testable without the
-// native static libraries.
-package servermode
-
-// NeedsDeepDoc reports whether a server mode must register and serve the
-// in-process (Go) DeepDoc backend at startup.
-//
-// Only the modes that actually run the document parsing pipeline need it:
-// - "api": serves the dataflow debug endpoint, which parses uploaded
-// files in-process, and may parse via other api routes.
-// - "ingestor": runs the document ingestion/parsing pipeline.
-//
-// "admin" (management UI) and "syncer" (datasource sync) never instantiate the
-// DeepDoc analyzer, so they must not fail-fast when ORT + models are absent.
-func NeedsDeepDoc(mode string) bool {
- switch mode {
- case "api", "ingestor":
- return true
- default:
- return false
- }
-}
diff --git a/internal/servermode/servermode_test.go b/internal/servermode/servermode_test.go
deleted file mode 100644
index 0e02f38bf3..0000000000
--- a/internal/servermode/servermode_test.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// The gate predicate is pure policy with no cgo dependency, so it is tested in
-// the default unit tier and runs without the native static libraries.
-package servermode
-
-import "testing"
-
-func TestNeedsDeepDoc(t *testing.T) {
- cases := []struct {
- mode string
- want bool
- }{
- // Modes that run the document parsing pipeline:
- {"api", true}, // serves dataflow debug, which parses in-process
- {"ingestor", true}, // runs the document ingestion/parsing pipeline
- // Modes that never instantiate the DeepDoc analyzer:
- {"admin", false}, // management UI
- {"syncer", false}, // datasource sync
- // Defensive against unknown/empty modes: do not fail-fast.
- {"", false},
- {"unknown", false},
- }
- for _, c := range cases {
- if got := NeedsDeepDoc(c.mode); got != c.want {
- t.Errorf("NeedsDeepDoc(%q) = %v, want %v", c.mode, got, c.want)
- }
- }
-}