diff --git a/docker/launch_backend_service.sh b/docker/launch_backend_service.sh index 10f7811349..8bd643155c 100755 --- a/docker/launch_backend_service.sh +++ b/docker/launch_backend_service.sh @@ -5,9 +5,12 @@ set -e usage() { local exit_code=${1:-1} - echo "Usage: $0 [ragflow|task_executor|admin|data_sync]..." + echo "Usage: $0 [OPTIONS] [ragflow|task_executor|admin|data_sync]..." echo echo "Without arguments, starts ragflow and task_executor." + echo "Options:" + echo " --debug Enable debug mode and debug-level logging" + echo echo "Available service types:" echo " ragflow Start RAGFlow server based on API_PROXY_SCHEME" echo " task_executor Start task workers based on API_PROXY_SCHEME" @@ -16,6 +19,7 @@ usage() { echo echo "Examples:" echo " $0" + echo " $0 --debug" echo " $0 ragflow" echo " $0 task_executor" echo " $0 admin" @@ -99,10 +103,13 @@ task_exe(){ prepare_for_go task_name="ragflow_server --ingestor" task_cmd=("bin/ragflow_server" "--ingestor") + if [[ "$DEBUG_MODE" -eq 1 ]]; then + task_cmd+=("--debug") + fi fi local retry_count=0 while ! $STOP && [ $retry_count -lt $MAX_RETRIES ]; do - echo "Starting $task_name (Attempt $((retry_count+1)))" + echo "Starting ${task_cmd[*]} (Attempt $((retry_count+1)))" EXIT_CODE=0 if [[ "${API_PROXY_SCHEME}" == "go" ]]; then "${task_cmd[@]}" || EXIT_CODE=$? @@ -134,9 +141,12 @@ run_server(){ server_name="ragflow_server" server_cmd=("bin/ragflow_server" "--api") fi + if [[ "$DEBUG_MODE" -eq 1 ]]; then + server_cmd+=("--debug") + fi local retry_count=0 while ! $STOP && [ $retry_count -lt $MAX_RETRIES ]; do - echo "Starting $server_name (Attempt $((retry_count+1)))" + echo "Starting ${server_cmd[*]} (Attempt $((retry_count+1)))" EXIT_CODE=0 "${server_cmd[@]}" || EXIT_CODE=$? if [ $EXIT_CODE -eq 0 ]; then @@ -163,10 +173,13 @@ run_admin_server(){ prepare_for_go server_name="admin_server" server_cmd=("bin/ragflow_server" "--admin") + if [[ "$DEBUG_MODE" -eq 1 ]]; then + server_cmd+=("--debug") + fi fi local retry_count=0 while ! $STOP && [ $retry_count -lt $MAX_RETRIES ]; do - echo "Starting $server_name (Attempt $((retry_count+1)))" + echo "Starting ${server_cmd[*]} (Attempt $((retry_count+1)))" EXIT_CODE=0 "${server_cmd[@]}" || EXIT_CODE=$? if [ $EXIT_CODE -eq 0 ]; then @@ -245,31 +258,36 @@ START_RAGFLOW=0 START_TASK_EXECUTOR=0 START_ADMIN=0 START_DATA_SYNC=0 - -if [ $# -eq 0 ]; then - START_RAGFLOW=1 - START_TASK_EXECUTOR=1 -fi +DEBUG_MODE=0 +SERVICE_SELECTED=0 for arg in "$@"; do case $arg in ragflow|server|webserver) START_RAGFLOW=1 + SERVICE_SELECTED=1 ;; task_executor|task-executor|taskexecutor|ingestor) START_TASK_EXECUTOR=1 + SERVICE_SELECTED=1 ;; admin|admin_server|admin-server) START_ADMIN=1 + SERVICE_SELECTED=1 ;; data_sync|data-sync|datasync) START_DATA_SYNC=1 + SERVICE_SELECTED=1 ;; all) START_RAGFLOW=1 START_TASK_EXECUTOR=1 START_ADMIN=1 START_DATA_SYNC=1 + SERVICE_SELECTED=1 + ;; + --debug) + DEBUG_MODE=1 ;; -h|--help) usage 0 @@ -281,6 +299,15 @@ for arg in "$@"; do esac done +if [[ "$DEBUG_MODE" -eq 1 && "${API_PROXY_SCHEME}" != "go" ]]; then + export LOG_LEVELS="root=DEBUG" +fi + +if [[ "$SERVICE_SELECTED" -eq 0 ]]; then + START_RAGFLOW=1 + START_TASK_EXECUTOR=1 +fi + if [[ "$START_RAGFLOW" -eq 1 ]]; then ensure_db_init run_mysql_migrations