SherryLiu пре 7 месеци
родитељ
комит
91bda75d4f
1 измењених фајлова са 49 додато и 64 уклоњено
  1. 49 64
      run.sh

+ 49 - 64
run.sh

@@ -1,80 +1,65 @@
 #!/bin/bash
 
 # Set environment variables
-export OPENAI_API_KEY="sk-proj-kGQPjKXup6g5QmjWvN3GT3BlbkFJDOYyhv8auoHBDIznmbgj"
-export SUPABASE_URI=postgresql://postgres:chuz8310xsystex@db.ptt.cx:5432/postgres
-export SUPABASE_URL="http://db.ptt.cx:8000/"
-export SUPABASE_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q"
+# export OPENAI_API_KEY="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"
+# export SUPABASE_URI=postgresql://postgres:chuz8310xsystex@db.ptt.cx:5432/postgres
+# export SUPABASE_URL="http://db.ptt.cx:8000/"
+# export SUPABASE_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q"
 
 
-Function to check if Docker is running
-start_docker() {
-    if ! docker info > /dev/null 2>&1; then
-        echo "Starting Docker Desktop..."
-        open --background -a Docker
-        # Wait until Docker daemon is running
-        while ! docker info > /dev/null 2>&1; do
-            echo "Waiting for Docker to start..."
-            sleep 1
-        done
-        echo "Docker started."
-    else
-        echo "Docker is already running."
-    fi
+# #########################################
+# Function to check if Docker is running
+docker_running() {
+    docker info >/dev/null 2>&1
 }
 
-#########################################
-# # Start Docker if it's not already running
-# if ! systemctl is-active --quiet docker; then
-#     echo "Starting Docker..."
-#     sudo systemctl start docker
-#     sleep 5  # Wait for Docker to fully start
-# fi
-
-# # Get the script directory
-# script_dir=$(dirname "$0")
-
-# # Change to the directory containing the docker-compose.yml file
-# cd "$script_dir"
-
-# # Start the services defined in docker-compose.yml
-# echo "Starting services with Docker Compose..."
-# docker-compose up -d
-
-# # Wait for services to be fully up
-# echo "Waiting for services to start..."
-# sleep 20  # Adjust this time as needed
+# Start Docker if it's not already running
+if ! docker_running; then
+    echo "Starting Docker..."
+    open -a Docker
+    
+    # Wait for Docker to start
+    while ! docker_running; do
+        echo "Waiting for Docker to start..."
+        sleep 5
+    done
+    echo "Docker is now running"
+fi
 
-# # Change to the directory containing your Python script
-# cd "$script_dir/systex-RAG-sherry"
+# Get the script directory
+script_dir=$(dirname "$0")
+cd "$script_dir"
 
-# Run your Python script
-# echo "Running RAG application..."
-# python RAG_app_copy.py
+# Start the services defined in docker-compose.yml
+echo "Starting services with Docker Compose..."
+docker-compose up -d
+echo "Waiting for services to start..."
+sleep 20 
 
-##########################################
+# Change to the directory containing Python script
+cd "$script_dir/systex-RAG-sherry"
+echo "Running RAG application..."
+python RAG_app_copy.py
 
-# Check and manage Redis Stack container
-if [ "$(docker ps -a -q -f name=redis-stack)" ]; then
-    if [ ! "$(docker ps -q -f name=redis-stack)" ]; then
-        echo "Starting existing Redis Stack container..."
-        docker start redis-stack
-    else
-        echo "Redis Stack container is already running."
-    fi
-else
-    echo "Creating and starting Redis Stack container..."
-    docker run -d --name redis-stack -p 6380:6379 redis/redis-stack:latest
-fi
+# # Check and manage Redis Stack container
+# if [ "$(docker ps -a -q -f name=redis-stack)" ]; then
+#     if [ ! "$(docker ps -q -f name=redis-stack)" ]; then
+#         echo "Starting existing Redis Stack container..."
+#         docker start redis-stack
+#     else
+#         echo "Redis Stack container is already running."
+#     fi
+# else
+#     echo "Creating and starting Redis Stack container..."
+#     docker run -d --name redis-stack -p 6380:6379 redis/redis-stack:latest
+# fi
 
-# Check if Redis container started successfully
-if [ ! "$(docker ps -q -f name=redis-stack)" ]; then
-    echo "Redis Stack container failed to start. Exiting script."
-    exit 1
-fi
+# # Check if Redis container started successfully
+# if [ ! "$(docker ps -q -f name=redis-stack)" ]; then
+#     echo "Redis Stack container failed to start. Exiting script."
+#     exit 1
+# fi
 
-echo "Running RAG application..."
-python RAG_app_copy.py
 
 # 使脚本文件可执行:
 # chmod +x run.sh