mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-10-11 21:39:54 +00:00
refactor: Update entrypoint.sh (#20744)
Signed-off-by: Jin Hai <[email protected]>
This commit is contained in:
@@ -66,7 +66,6 @@ COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
|
||||
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
|
||||
|
||||
ENV PYTHONPATH=/ragflow/
|
||||
# copy entrypoint.sh and entrypoint-pasar.sh
|
||||
COPY docker/service_conf.yaml.template ./conf/service_conf.yaml.template
|
||||
COPY docker/entrypoint*.sh ./
|
||||
RUN chmod +x ./entrypoint*.sh
|
||||
|
||||
@@ -22,7 +22,6 @@ services:
|
||||
|
||||
# Example configuration to start Admin server:
|
||||
command:
|
||||
- --enable-adminserver
|
||||
- --init-superuser
|
||||
#- --init-model-provider-tables
|
||||
ports:
|
||||
|
||||
+34
-89
@@ -2,7 +2,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
echo "Start RAGFlow cluster, version: "
|
||||
echo "Start RAGFlow, version: "
|
||||
cat /ragflow/VERSION
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
@@ -11,70 +11,44 @@ cat /ragflow/VERSION
|
||||
function usage() {
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo
|
||||
echo " --disable-webserver Disables the web server (nginx + ragflow_server)."
|
||||
echo " --disable-taskexecutor Disables task executor workers."
|
||||
echo " --disable-datasync Disables synchronization of datasource workers."
|
||||
echo " --enable-adminserver Enables the Admin server."
|
||||
echo " --init-model-provider-tables Run model provider table migrations and exit."
|
||||
echo " --init-superuser Initializes the superuser (needs --enable-adminserver)."
|
||||
echo " --consumer-no-beg=<num> Start range for consumers (if using range-based)."
|
||||
echo " --consumer-no-end=<num> End range for consumers (if using range-based)."
|
||||
echo " --workers=<num> Number of task executors to run (if range is not used)."
|
||||
echo " --host-id=<string> Unique ID for the host (defaults to \`hostname\`)."
|
||||
echo " --disable-api-server Disables the web server (nginx + ragflow_server)."
|
||||
echo " --disable-ingestor Disables ingestor."
|
||||
echo " --disable-syncer Disables data source syncer."
|
||||
echo " --init-model-provider-tables Run model provider table migrations and exit."
|
||||
echo " --init-superuser Initializes the superuser."
|
||||
echo " --ingestors=<num> Number of ingestors to run."
|
||||
|
||||
echo
|
||||
echo "Examples:"
|
||||
echo " $0 --disable-taskexecutor"
|
||||
echo " $0 --disable-webserver --consumer-no-beg=0 --consumer-no-end=5"
|
||||
echo " $0 --disable-webserver --workers=2 --host-id=myhost123"
|
||||
echo " $0 --enable-adminserver"
|
||||
echo " $0 --enable-adminserver --init-superuser"
|
||||
echo " $0 --disable-ingestor"
|
||||
echo " $0 --disable-api-server --ingestors=2"
|
||||
echo " $0 --init-superuser"
|
||||
exit 1
|
||||
}
|
||||
|
||||
ENABLE_WEBSERVER=1 # Default to enable web server
|
||||
ENABLE_TASKEXECUTOR=1 # Default to enable task executor
|
||||
ENABLE_API_SERVER=1 # Default to enable web server
|
||||
ENABLE_INGESTOR=1 # Default to enable ingestor
|
||||
ENABLE_DATASYNC=1
|
||||
ENABLE_ADMIN_SERVER=0 # Default close admin server
|
||||
|
||||
INIT_SUPERUSER_ARGS="" # Default to not initialize superuser
|
||||
INIT_MODEL_PROVIDER_TABLES=0
|
||||
CONSUMER_NO_BEG=0
|
||||
CONSUMER_NO_END=0
|
||||
WORKERS=1
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Host ID logic:
|
||||
# 1. By default, use the system hostname if length <= 32
|
||||
# 2. Otherwise, use the full MD5 hash of the hostname (32 hex chars)
|
||||
# -----------------------------------------------------------------------------
|
||||
CURRENT_HOSTNAME="$(hostname)"
|
||||
if [ ${#CURRENT_HOSTNAME} -le 32 ]; then
|
||||
DEFAULT_HOST_ID="$CURRENT_HOSTNAME"
|
||||
else
|
||||
DEFAULT_HOST_ID="$(echo -n "$CURRENT_HOSTNAME" | md5sum | cut -d ' ' -f 1)"
|
||||
fi
|
||||
|
||||
HOST_ID="$DEFAULT_HOST_ID"
|
||||
INGESTOR_NUMBER=1
|
||||
|
||||
# Parse arguments
|
||||
for arg in "$@"; do
|
||||
case $arg in
|
||||
--disable-webserver)
|
||||
ENABLE_WEBSERVER=0
|
||||
--disable-api-server)
|
||||
ENABLE_API_SERVER=0
|
||||
shift
|
||||
;;
|
||||
--disable-taskexecutor)
|
||||
ENABLE_TASKEXECUTOR=0
|
||||
--disable-ingestor)
|
||||
ENABLE_INGESTOR=0
|
||||
shift
|
||||
;;
|
||||
--disable-datasync)
|
||||
--disable-syncer)
|
||||
ENABLE_DATASYNC=0
|
||||
shift
|
||||
;;
|
||||
--enable-adminserver)
|
||||
ENABLE_ADMIN_SERVER=1
|
||||
shift
|
||||
;;
|
||||
--init-model-provider-tables)
|
||||
INIT_MODEL_PROVIDER_TABLES=1
|
||||
shift
|
||||
@@ -83,20 +57,8 @@ for arg in "$@"; do
|
||||
INIT_SUPERUSER_ARGS="--init-superuser"
|
||||
shift
|
||||
;;
|
||||
--consumer-no-beg=*)
|
||||
CONSUMER_NO_BEG="${arg#*=}"
|
||||
shift
|
||||
;;
|
||||
--consumer-no-end=*)
|
||||
CONSUMER_NO_END="${arg#*=}"
|
||||
shift
|
||||
;;
|
||||
--workers=*)
|
||||
WORKERS="${arg#*=}"
|
||||
shift
|
||||
;;
|
||||
--host-id=*)
|
||||
HOST_ID="${arg#*=}"
|
||||
--ingestors=*)
|
||||
INGESTOR_NUMBER="${arg#*=}"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
@@ -156,7 +118,7 @@ function go_backend_enabled() {
|
||||
if [[ "${ENABLE_DATASYNC}" -eq 1 ]]; then
|
||||
return 0
|
||||
fi
|
||||
if [[ "${ENABLE_ADMIN_SERVER}" -eq 1 ]] || [[ "${ENABLE_WEBSERVER}" -eq 1 ]]; then
|
||||
if [[ "${ENABLE_API_SERVER}" -eq 1 ]]; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
@@ -194,19 +156,10 @@ if go_backend_enabled; then
|
||||
run_go_migrations
|
||||
fi
|
||||
|
||||
if [[ "${ENABLE_DATASYNC}" -eq 1 ]]; then
|
||||
echo "Starting data sync..."
|
||||
run_with_restart "RAGFlow go server" bin/ragflow_server --syncer &
|
||||
fi
|
||||
echo "Starting Admin go server..."
|
||||
run_with_restart "Admin go server" bin/ragflow_server --admin ${INIT_SUPERUSER_ARGS} &
|
||||
|
||||
sleep 5
|
||||
|
||||
if [[ "${ENABLE_ADMIN_SERVER}" -eq 1 ]]; then
|
||||
echo "Starting Admin go server..."
|
||||
run_with_restart "Admin go server" bin/ragflow_server --admin ${INIT_SUPERUSER_ARGS} &
|
||||
fi
|
||||
|
||||
if [[ "${ENABLE_WEBSERVER}" -eq 1 ]]; then
|
||||
if [[ "${ENABLE_API_SERVER}" -eq 1 ]]; then
|
||||
echo "Starting nginx..."
|
||||
/usr/sbin/nginx -c /etc/nginx/nginx.conf
|
||||
|
||||
@@ -214,25 +167,17 @@ if [[ "${ENABLE_WEBSERVER}" -eq 1 ]]; then
|
||||
run_with_restart "RAGFlow go server" bin/ragflow_server --api &
|
||||
fi
|
||||
|
||||
# MCP configuration comes from service_conf.yaml and RAGFLOW_MCP_* environment
|
||||
# variables. The API process owns its optional standalone listener.
|
||||
if [[ "${ENABLE_DATASYNC}" -eq 1 ]]; then
|
||||
echo "Starting data sync..."
|
||||
run_with_restart "RAGFlow go server" bin/ragflow_server --syncer &
|
||||
fi
|
||||
|
||||
# Task execution is the Go ingestor's job. This image ships no Python task
|
||||
# executor (rag/svr/task_executor.py is not copied), so --ingestor is the only
|
||||
# worker that can run here.
|
||||
if [[ "${ENABLE_TASKEXECUTOR}" -eq 1 ]]; then
|
||||
if [[ "${CONSUMER_NO_END}" -gt "${CONSUMER_NO_BEG}" ]]; then
|
||||
echo "Starting go ingestor..."
|
||||
if [[ "${ENABLE_INGESTOR}" -eq 1 ]]; then
|
||||
echo "Starting ${INGESTOR_NUMBER} ingestor worker(s)..."
|
||||
for (( i=0; i<INGESTOR_NUMBER; i++ ))
|
||||
do
|
||||
run_with_restart "ingestor" bin/ragflow_server --ingestor &
|
||||
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
|
||||
echo "Starting go ingestor..."
|
||||
run_with_restart "ingestor" bin/ragflow_server --ingestor &
|
||||
done
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
wait
|
||||
|
||||
Reference in New Issue
Block a user