Files

45 lines
1.3 KiB
Bash
Raw Permalink Normal View History

2025-05-09 15:41:16 +01:00
#!/bin/bash
# Stop any existing service
pkill -f "uvicorn ai_service.api:app" || true
2025-05-09 16:47:30 +01:00
pkill -f "run_ai_service.py" || true
2025-05-09 15:41:16 +01:00
# Create data directory if it doesn't exist
mkdir -p ai_service/data
# Create empty files for local storage if they don't exist
touch ai_service/data/document_metadata.json
touch ai_service/data/chats.json
2025-05-09 16:47:30 +01:00
# Start the AI service
2025-05-09 20:00:26 +01:00
echo "Starting AI Service on port 5252..."
2025-05-09 15:41:16 +01:00
VENV_PATH="./venv"
PYTHON_PATH="$VENV_PATH/bin/python"
# Check if the virtual environment exists
if [ -f "$PYTHON_PATH" ]; then
echo "Using Python from virtual environment: $PYTHON_PATH"
2025-05-09 16:47:30 +01:00
nohup $PYTHON_PATH run_ai_service.py > ai_service.log 2>&1 &
2025-05-09 15:41:16 +01:00
else
echo "Virtual environment not found at $VENV_PATH, using system Python"
2025-05-09 16:47:30 +01:00
nohup python run_ai_service.py > ai_service.log 2>&1 &
2025-05-09 15:41:16 +01:00
fi
# Wait a moment for the service to start
sleep 2
# Check if the service is running
2025-05-09 16:47:30 +01:00
if pgrep -f "run_ai_service.py" > /dev/null; then
2025-05-09 20:00:26 +01:00
echo "AI Service started successfully on port 5252"
2025-05-09 15:41:16 +01:00
echo "Check ai_service.log for output"
2025-05-09 16:47:30 +01:00
echo "To stop the service, run: pkill -f \"run_ai_service.py\""
2025-05-09 15:41:16 +01:00
2025-05-20 02:18:46 +01:00
# Check the health endpoint
echo -e "\nChecking health endpoint..."
2025-05-09 20:00:26 +01:00
curl -s http://localhost:5252/health
2025-05-09 15:41:16 +01:00
echo -e "\n"
else
echo "Failed to start AI Service. Check ai_service.log for errors."
exit 1
fi