mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-01 05:23:47 +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:
60
build.sh
60
build.sh
@@ -14,9 +14,7 @@ PROJECT_ROOT="$SCRIPT_DIR"
|
||||
# Build directories
|
||||
CPP_DIR="$PROJECT_ROOT/internal/cpp"
|
||||
BUILD_DIR="$CPP_DIR/cmake-build-release"
|
||||
RAGFLOW_SERVER_BINARY="$PROJECT_ROOT/bin/ragflow_server"
|
||||
ADMIN_SERVER_BINARY="$PROJECT_ROOT/bin/admin_server"
|
||||
INGESTOR_BINARY="$PROJECT_ROOT/bin/ingestor"
|
||||
RAGFLOW_MAIN_BINARY="$PROJECT_ROOT/bin/ragflow_main"
|
||||
RAGFLOW_CLI_BINARY="$PROJECT_ROOT/bin/ragflow-cli"
|
||||
|
||||
# Strip symbols from Go binaries (set via --strip / -s)
|
||||
@@ -46,7 +44,10 @@ _seed_from_system() {
|
||||
local dep_dir="${HOME}/ragflow-native-libs/${dep_name}"
|
||||
local sys_dir="${SYSTEM_DEPS}/${dep_name}"
|
||||
|
||||
echo "check if dep ${dep_name} exists in ${dep_dir} or ${sys_dir}"
|
||||
|
||||
if [ -d "$dep_dir" ]; then
|
||||
echo " ${dep_name} → ${dep_dir} (user cache)"
|
||||
return 0 # already cached
|
||||
fi
|
||||
if [ -d "$sys_dir" ]; then
|
||||
@@ -55,6 +56,7 @@ _seed_from_system() {
|
||||
cp -r "$sys_dir" "$dep_dir"
|
||||
return 0
|
||||
fi
|
||||
echo " ${dep_name} not found in system or user cache"
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -299,39 +301,21 @@ build_go() {
|
||||
local strip_flags=()
|
||||
[ -n "$STRIP_SYMBOLS" ] && strip_flags=(-ldflags="-s -w")
|
||||
|
||||
echo "Building RAGFlow binary: $RAGFLOW_SERVER_BINARY, $ADMIN_SERVER_BINARY, $INGESTOR_BINARY, and $RAGFLOW_CLI_BINARY"
|
||||
echo "Building RAGFlow binary: $RAGFLOW_MAIN_BINARY, and $RAGFLOW_CLI_BINARY"
|
||||
GOPROXY=${GOPROXY:-https://goproxy.cn,https://proxy.golang.org,direct} CGO_ENABLED=1 \
|
||||
CGO_CFLAGS="$CGO_CFLAGS" CGO_LDFLAGS="$CGO_LDFLAGS" \
|
||||
go build "${strip_flags[@]}" -o "$RAGFLOW_SERVER_BINARY" cmd/server_main.go
|
||||
GOPROXY=${GOPROXY:-https://goproxy.cn,https://proxy.golang.org,direct} CGO_ENABLED=1 \
|
||||
CGO_CFLAGS="$CGO_CFLAGS" CGO_LDFLAGS="$CGO_LDFLAGS" \
|
||||
go build "${strip_flags[@]}" -o "$ADMIN_SERVER_BINARY" cmd/admin_server.go
|
||||
GOPROXY=${GOPROXY:-https://goproxy.cn,https://proxy.golang.org,direct} CGO_ENABLED=1 \
|
||||
CGO_CFLAGS="$CGO_CFLAGS" CGO_LDFLAGS="$CGO_LDFLAGS" \
|
||||
go build "${strip_flags[@]}" -o "$INGESTOR_BINARY" cmd/ingestor.go
|
||||
go build "${strip_flags[@]}" -o "$RAGFLOW_MAIN_BINARY" cmd/ragflow_main.go
|
||||
GOPROXY=${GOPROXY:-https://goproxy.cn,https://proxy.golang.org,direct} CGO_ENABLED=1 \
|
||||
CGO_CFLAGS="$CGO_CFLAGS" CGO_LDFLAGS="$CGO_LDFLAGS" \
|
||||
go build "${strip_flags[@]}" -o "$RAGFLOW_CLI_BINARY" cmd/ragflow-cli.go
|
||||
|
||||
if [ ! -f "$RAGFLOW_SERVER_BINARY" ]; then
|
||||
echo -e "${RED}Error: Failed to build RAGFlow server binary${NC}"
|
||||
if [ ! -f "$RAGFLOW_MAIN_BINARY" ]; then
|
||||
echo -e "${RED}Error: Failed to build RAGFlow main binary${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$ADMIN_SERVER_BINARY" ]; then
|
||||
echo -e "${RED}Error: Failed to build Admin server binary${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$INGESTOR_BINARY" ]; then
|
||||
echo -e "${RED}Error: Failed to build Ingestor binary${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✓ Go ragflow_server built successfully: $RAGFLOW_SERVER_BINARY${NC}"
|
||||
echo -e "${GREEN}✓ Go admin_server built successfully: $ADMIN_SERVER_BINARY${NC}"
|
||||
echo -e "${GREEN}✓ Go ragflow_main built successfully: $RAGFLOW_MAIN_BINARY${NC}"
|
||||
echo -e "${GREEN}✓ Go ragflow-cli built successfully: $RAGFLOW_CLI_BINARY${NC}"
|
||||
echo -e "${GREEN}✓ Go ingestor built successfully: $INGESTOR_BINARY${NC}"
|
||||
}
|
||||
|
||||
# Configure CGO flags for native libraries (office_oxide, pdfium, pdf_oxide).
|
||||
@@ -421,9 +405,7 @@ clean() {
|
||||
print_section "Cleaning build artifacts"
|
||||
|
||||
rm -rf "$BUILD_DIR"
|
||||
rm -f "$RAGFLOW_SERVER_BINARY"
|
||||
rm -f "$ADMIN_SERVER_BINARY"
|
||||
rm -f "$INGESTOR_BINARY"
|
||||
rm -f "$RAGFLOW_MAIN_BINARY"
|
||||
rm -f "$RAGFLOW_CLI_BINARY"
|
||||
|
||||
echo -e "${GREEN}✓ Build artifacts cleaned${NC}"
|
||||
@@ -431,16 +413,8 @@ clean() {
|
||||
|
||||
# Run the server
|
||||
run() {
|
||||
if [ ! -f "$ADMIN_SERVER_BINARY" ]; then
|
||||
echo -e "${RED}Error: $ADMIN_SERVER_BINARY not found. Build first with --all or --go${NC}"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$RAGFLOW_SERVER_BINARY" ]; then
|
||||
echo -e "${RED}Error: $RAGFLOW_SERVER_BINARY not found. Build first with --all or --go${NC}"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$INGESTOR_BINARY" ]; then
|
||||
echo -e "${RED}Error: $INGESTOR_BINARY not found. Build first with --all or --go${NC}"
|
||||
if [ ! -f "$RAGFLOW_MAIN_BINARY" ]; then
|
||||
echo -e "${RED}Error: $RAGFLOW_MAIN_BINARY not found. Build first with --all or --go${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -449,7 +423,7 @@ run() {
|
||||
# admin_server must be running before ragflow_server, otherwise ragflow_server's
|
||||
# heartbeats to admin will error out (see internal/development.md).
|
||||
print_section "Starting admin server (background)"
|
||||
"$ADMIN_SERVER_BINARY" &
|
||||
"$RAGFLOW_MAIN_BINARY" --admin &
|
||||
ADMIN_PID=$!
|
||||
trap 'kill "$ADMIN_PID" 2>/dev/null || true' EXIT INT TERM
|
||||
|
||||
@@ -458,13 +432,13 @@ run() {
|
||||
sleep 1
|
||||
|
||||
print_section "Starting ingestor (background)"
|
||||
"$INGESTOR_BINARY" &
|
||||
"$RAGFLOW_MAIN_BINARY" --ingestor &
|
||||
INGESTOR_PID=$!
|
||||
trap 'kill "$INGESTOR_PID" 2>/dev/null || true' EXIT INT TERM
|
||||
sleep 1
|
||||
|
||||
print_section "Starting RAGFlow server (foreground)"
|
||||
"$RAGFLOW_SERVER_BINARY"
|
||||
"$RAGFLOW_MAIN_BINARY" -- api
|
||||
}
|
||||
|
||||
# Show help
|
||||
@@ -566,7 +540,7 @@ main() {
|
||||
build_cpp
|
||||
build_go
|
||||
echo -e "\n${GREEN}=== Build completed successfully! ===${NC}"
|
||||
echo "Binary: $RAGFLOW_SERVER_BINARY, $ADMIN_SERVER_BINARY, $INGESTOR_BINARY, $RAGFLOW_CLI_BINARY"
|
||||
echo "Binary: $RAGFLOW_MAIN_BINARY, $RAGFLOW_CLI_BINARY"
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Unknown option: $1${NC}"
|
||||
|
||||
Reference in New Issue
Block a user