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:
Jin Hai
2026-07-02 21:21:10 +08:00
committed by GitHub
parent 32c5cb16e9
commit 7d64a78f83
19 changed files with 761 additions and 770 deletions

View File

@@ -159,6 +159,7 @@ GO_HTTP_PORT=9384
GO_ADMIN_PORT=9383
# API_PROXY_SCHEME=hybrid # go and python hybrid deploy mode
# API_PROXY_SCHEME=go # use go server deployment
API_PROXY_SCHEME=python # use pure python server deployment
# Development-only: set to 1 to bypass host safety checks for test_db_connection and allow private/local database hosts.

View File

@@ -248,24 +248,6 @@ function ensure_db_init() {
echo "Database tables initialized."
}
function wait_for_server() {
local url="$1"
local server_name="$2"
local timeout=90
local interval=2
local start_time=$(date +%s)
echo "Waiting for $server_name to be ready at $url..."
while ! curl -f -s -o /dev/null "$url"; do
if [ $(($(date +%s) - start_time)) -gt $timeout ]; then
echo "Timeout waiting for $server_name after $timeout seconds"
return 1
fi
sleep $interval
done
echo "$server_name is ready."
}
# -----------------------------------------------------------------------------
# Start components based on flags
# -----------------------------------------------------------------------------
@@ -283,43 +265,44 @@ if [[ "${INIT_MODEL_PROVIDER_TABLES}" -eq 1 ]]; then
echo "Model provider table migrations completed."
fi
if [[ "${ENABLE_WEBSERVER}" -eq 1 ]]; then
echo "Starting nginx..."
/usr/sbin/nginx
while true; do
echo "Attempt to start RAGFlow server..."
"$PY" api/ragflow_server.py ${INIT_SUPERUSER_ARGS}
echo "RAGFlow python server started."
sleep 1;
done &
if [[ "${ENABLE_ADMIN_SERVER}" -eq 1 ]]; then
if [[ "${API_PROXY_SCHEME}" == "hybrid" ]] || [[ "${API_PROXY_SCHEME}" == "python" ]]; then
while true; do
echo "Attempt to start Admin python server..."
"$PY" admin/server/admin_server.py
echo "Admin python server started"
sleep 1;
done &
fi
if [[ "${API_PROXY_SCHEME}" == "hybrid" ]] || [[ "${API_PROXY_SCHEME}" == "go" ]]; then
while true; do
echo "Attempt to start RAGFlow go server..."
wait_for_server "http://127.0.0.1:9380/api/v1/system/healthz" "ragflow_server"
echo "Starting RAGFlow go server..."
bin/ragflow_server
echo "Starting Admin go server..."
bin/ragflow_main --admin
echo "Admin go server started."
sleep 1;
done &
fi
fi
if [[ "${ENABLE_WEBSERVER}" -eq 1 ]]; then
echo "Starting nginx..."
/usr/sbin/nginx
if [[ "${ENABLE_ADMIN_SERVER}" -eq 1 ]]; then
while true; do
echo "Attempt to start Admin python server..."
"$PY" admin/server/admin_server.py
echo "Admin python server started"
sleep 1;
done &
if [[ "${API_PROXY_SCHEME}" == "hybrid" ]] || [[ "${API_PROXY_SCHEME}" == "python" ]]; then
while true; do
echo "Attempt to start RAGFlow python server..."
"$PY" api/ragflow_server.py ${INIT_SUPERUSER_ARGS}
echo "RAGFlow python server started."
sleep 1;
done &
fi
if [[ "${API_PROXY_SCHEME}" == "hybrid" ]] || [[ "${API_PROXY_SCHEME}" == "go" ]]; then
while true; do
echo "Attempt to starting Admin go server..."
wait_for_server "http://127.0.0.1:9381/api/v1/admin/ping" "admin_server"
echo "Starting Admin go server..."
bin/admin_server
echo "Starting RAGFlow go server..."
bin/ragflow_main --api
echo "RAGFlow go server started."
sleep 1;
done &
fi
@@ -341,17 +324,39 @@ fi
if [[ "${ENABLE_TASKEXECUTOR}" -eq 1 ]]; then
if [[ "${CONSUMER_NO_END}" -gt "${CONSUMER_NO_BEG}" ]]; then
echo "Starting task executors on host '${HOST_ID}' for IDs in [${CONSUMER_NO_BEG}, ${CONSUMER_NO_END})..."
for (( i=CONSUMER_NO_BEG; i<CONSUMER_NO_END; i++ ))
do
task_exe "${i}" "${HOST_ID}" &
done
if [[ "${API_PROXY_SCHEME}" == "hybrid" ]] || [[ "${API_PROXY_SCHEME}" == "python" ]]; then
echo "Starting python task executors on host '${HOST_ID}' for IDs in [${CONSUMER_NO_BEG}, ${CONSUMER_NO_END})..."
for (( i=CONSUMER_NO_BEG; i<CONSUMER_NO_END; i++ ))
do
task_exe "${i}" "${HOST_ID}" &
done
fi
if [[ "${API_PROXY_SCHEME}" == "hybrid" ]] || [[ "${API_PROXY_SCHEME}" == "go" ]]; then
while true; do
echo "Starting go ingestor..."
bin/ragflow_main --ingestor
sleep 1;
done &
fi
else
# Otherwise, start a fixed number of workers
echo "Starting ${WORKERS} task executor(s) on host '${HOST_ID}'..."
for (( i=0; i<WORKERS; i++ ))
do
task_exe "${i}" "${HOST_ID}" &
if [[ "${API_PROXY_SCHEME}" == "hybrid" ]] || [[ "${API_PROXY_SCHEME}" == "python" ]]; then
echo "Starting python task executor..."
task_exe "${i}" "${HOST_ID}" &
sleep 1;
fi
if [[ "${API_PROXY_SCHEME}" == "hybrid" ]] || [[ "${API_PROXY_SCHEME}" == "go" ]]; then
while true; do
echo "Starting go ingestor..."
bin/ragflow_main --ingestor
sleep 1;
done &
fi
done
fi
fi

View File

@@ -63,6 +63,8 @@ redis:
nats:
host: ${NATS_HOST:-0.0.0.0}
port: ${NATS_PORT:-4222}
task_executor:
message_queue_type: 'nats'
user_default_llm:
default_models:
embedding_model: