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
Go: add pprof, use --profile to turn on (#19858)
Jin Hai9c4ffed6129b
diff --git a/cmd/ragflow_server.go b/cmd/ragflow_server.goindex d11d8140e8..1af2f2eb3f 100644--- a/cmd/ragflow_server.go+++ b/cmd/ragflow_server.go@@ -22,6 +22,7 @@ import ("fmt""net""net/http"+ _ "net/http/pprof""os""os/signal""path/filepath"@@ -88,6 +89,7 @@ type serverArgs struct {adminHost *string // Used by api, ingestor, syncer for heartbeatadminPort *int // Used by api, ingestor, syncer for heartbeat, "ip:port"name *string // server name+ enablePProf bool // enable pprofmcpEnabled boolmcpHost stringmcpPort int@@ -299,6 +301,8 @@ func parseArgs() (*serverArgs, error) {}i++args.name = &os.Args[i]+ case "--profile":+ args.enablePProf = truedefault:return nil, fmt.Errorf("unknown parameter: %s", arg)}@@ -403,6 +407,7 @@ func printHelp(args *serverArgs) {fmt.Fprintf(os.Stderr, " --config string\tPath to configuration file\n")fmt.Fprintf(os.Stderr, " -v, --version \tPrint version information and exit\n")fmt.Fprintf(os.Stderr, " --debug \tEnable debug-level logging\n")+ fmt.Fprintf(os.Stderr, " --profile \t\tEnable pprof server\n")fmt.Fprintf(os.Stderr, " -h, --help \tShow this help message and exit\n\n")fmt.Fprintf(os.Stderr, "Run '%s --api --help' for API server options.\n", os.Args[0])fmt.Fprintf(os.Stderr, "Run '%s --admin --help' for admin server options.\n", os.Args[0])@@ -416,6 +421,7 @@ func printHelp(args *serverArgs) {fmt.Fprintf(os.Stderr, " -f --config string\tPath to configuration file\n")fmt.Fprintf(os.Stderr, " -v, --version \tPrint version information and exit\n")fmt.Fprintf(os.Stderr, " --debug \tEnable debug-level logging\n")+ fmt.Fprintf(os.Stderr, " --profile \t\tEnable pprof server\n")fmt.Fprintf(os.Stderr, " -h, --help \tShow this help message and exit\n")case *args.mode == "admin":fmt.Fprintf(os.Stderr, "Usage: %s --admin [OPTIONS]\n\n", os.Args[0])@@ -426,6 +432,7 @@ func printHelp(args *serverArgs) {fmt.Fprintf(os.Stderr, " --init-superuser\t\t\tInitialize superuser account\n")fmt.Fprintf(os.Stderr, " -v, --version \t\t\tPrint version information and exit\n")fmt.Fprintf(os.Stderr, " --debug \t\t\tEnable debug-level logging\n")+ fmt.Fprintf(os.Stderr, " --profile \t\t\tEnable pprof server\n")fmt.Fprintf(os.Stderr, " -h, --help \t\t\tShow this help message and exit\n")case *args.mode == "ingestor":fmt.Fprintf(os.Stderr, "Usage: %s --ingestor [OPTIONS]\n\n", os.Args[0])@@ -436,6 +443,7 @@ func printHelp(args *serverArgs) {fmt.Fprintf(os.Stderr, " --admin-host string\tAdmin server host:port (overrides config file)\n")fmt.Fprintf(os.Stderr, " -v, --version \t\tPrint version information and exit\n")fmt.Fprintf(os.Stderr, " --debug \t\tEnable debug-level logging\n")+ fmt.Fprintf(os.Stderr, " --profile \t\tEnable pprof server\n")fmt.Fprintf(os.Stderr, " -h, --help \t\tShow this help message and exit\n")case *args.mode == "syncer":fmt.Fprintf(os.Stderr, "Usage: %s --syncer [OPTIONS]\n\n", os.Args[0])@@ -446,6 +454,7 @@ func printHelp(args *serverArgs) {fmt.Fprintf(os.Stderr, " --admin-host string\tAdmin server host:port (overrides config file)\n")fmt.Fprintf(os.Stderr, " -v, --version \t\tPrint version information and exit\n")fmt.Fprintf(os.Stderr, " --debug \t\tEnable debug-level logging\n")+ fmt.Fprintf(os.Stderr, " --profile \t\tEnable pprof server\n")fmt.Fprintf(os.Stderr, " -h, --help \t\tShow this help message and exit\n")}}@@ -611,6 +620,16 @@ func main() {common.Info(fmt.Sprintf("Starting %s server: %s, mode: %s", *arguments.mode, serverName, globalConfig.GetMode()))server.PrintAll()+ // Start pprof server if requested+ if arguments.enablePProf {+ go func() {+ common.Info("Starting pprof server", zap.String("addr", "localhost:6060"))+ if pprofErr := http.ListenAndServe("localhost:6060", nil); pprofErr != nil {+ common.Error("pprof server failed", pprofErr)+ }+ }()+ }+// Initialize databaseif err = dao.InitDB(ctx, false); err != nil {common.Fatal("Failed to initialize database", zap.Error(err))