From db803764276bff9d85df0ed58215c578b5d71c44 Mon Sep 17 00:00:00 2001 From: Zhichang Yu Date: Mon, 20 Jan 2025 22:49:46 +0800 Subject: [PATCH] Added entrypoint for task executor (#4551) ### What problem does this PR solve? Added entrypoint for task executor ### Type of change - [x] Refactoring --- Dockerfile | 4 ++-- docker/docker-compose.yml | 24 +++++++++++++++++++++++- docker/entrypoint.sh | 3 --- docker/entrypoint_task_executor.sh | 28 ++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 6 deletions(-) create mode 100755 docker/entrypoint_task_executor.sh diff --git a/Dockerfile b/Dockerfile index 6b519073b..ba274ddbb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -183,8 +183,8 @@ COPY graphrag graphrag COPY pyproject.toml uv.lock ./ COPY docker/service_conf.yaml.template ./conf/service_conf.yaml.template -COPY docker/entrypoint.sh ./entrypoint.sh -RUN chmod +x ./entrypoint.sh +COPY docker/entrypoint.sh docker/entrypoint_task_executor.sh ./ +RUN chmod +x ./entrypoint*.sh # Copy compiled web pages COPY --from=builder /ragflow/web/dist /ragflow/web/dist diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 00901ddc7..676f167d6 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -26,6 +26,28 @@ services: - ragflow restart: on-failure # https://docs.docker.com/engine/daemon/prometheus/#create-a-prometheus-configuration - # If you're using Docker Desktop, the --add-host flag is optional. This flag makes sure that the host's internal IP gets exposed to the Prometheus container. + # If you're using Docker Desktop, the --add-host flag is optional. This flag makes sure that the host's internal IP gets exposed to the Prometheus container. extra_hosts: - "host.docker.internal:host-gateway" + # executor: + # depends_on: + # mysql: + # condition: service_healthy + # image: ${RAGFLOW_IMAGE} + # container_name: ragflow-executor + # volumes: + # - ./ragflow-logs:/ragflow/logs + # - ./nginx/ragflow.conf:/etc/nginx/conf.d/ragflow.conf + # env_file: .env + # environment: + # - TZ=${TIMEZONE} + # - HF_ENDPOINT=${HF_ENDPOINT} + # - MACOS=${MACOS} + # entrypoint: "/ragflow/entrypoint_task_executor.sh 1 3" + # networks: + # - ragflow + # restart: on-failure + # # https://docs.docker.com/engine/daemon/prometheus/#create-a-prometheus-configuration + # # If you're using Docker Desktop, the --add-host flag is optional. This flag makes sure that the host's internal IP gets exposed to the Prometheus container. + # extra_hosts: + # - "host.docker.internal:host-gateway" diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 792bbca7a..388102960 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -7,9 +7,6 @@ while IFS= read -r line || [[ -n "$line" ]]; do eval "echo \"$line\"" >> /ragflow/conf/service_conf.yaml done < /ragflow/conf/service_conf.yaml.template -# unset http proxy which maybe set by docker daemon -export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY="" - /usr/sbin/nginx export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/ diff --git a/docker/entrypoint_task_executor.sh b/docker/entrypoint_task_executor.sh new file mode 100755 index 000000000..899f16f8f --- /dev/null +++ b/docker/entrypoint_task_executor.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# replace env variables in the service_conf.yaml file +rm -rf /ragflow/conf/service_conf.yaml +while IFS= read -r line || [[ -n "$line" ]]; do + # Use eval to interpret the variable with default values + eval "echo \"$line\"" >> /ragflow/conf/service_conf.yaml +done < /ragflow/conf/service_conf.yaml.template + +export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/ + +PY=python3 + +CONSUMER_NO_BEG=$1 +CONSUMER_NO_END=$2 + +function task_exe(){ + while [ 1 -eq 1 ]; do + $PY rag/svr/task_executor.py $1; + done +} + +for ((i=CONSUMER_NO_BEG; i