45 lines
1.3 KiB
Bash
Executable File
45 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Stop any existing service
|
|
pkill -f "uvicorn ai_service.api:app" || true
|
|
pkill -f "run_ai_service.py" || true
|
|
|
|
# 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
|
|
|
|
# Start the AI service
|
|
echo "Starting AI Service on port 5252..."
|
|
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"
|
|
nohup $PYTHON_PATH run_ai_service.py > ai_service.log 2>&1 &
|
|
else
|
|
echo "Virtual environment not found at $VENV_PATH, using system Python"
|
|
nohup python run_ai_service.py > ai_service.log 2>&1 &
|
|
fi
|
|
|
|
# Wait a moment for the service to start
|
|
sleep 2
|
|
|
|
# Check if the service is running
|
|
if pgrep -f "run_ai_service.py" > /dev/null; then
|
|
echo "AI Service started successfully on port 5252"
|
|
echo "Check ai_service.log for output"
|
|
echo "To stop the service, run: pkill -f \"run_ai_service.py\""
|
|
|
|
# Check the health endpoint
|
|
echo -e "\nChecking health endpoint..."
|
|
curl -s http://localhost:5252/health
|
|
echo -e "\n"
|
|
else
|
|
echo "Failed to start AI Service. Check ai_service.log for errors."
|
|
exit 1
|
|
fi
|