#!/bin/bash # Startup script for chat service with documentation indexing set -e echo "=== Datacenter Documentation Chat Service ===" echo "Starting initialization..." # Check if vector store needs initialization VECTOR_STORE_PATH="/app/data/chroma_db" INDEX_MARKER="$VECTOR_STORE_PATH/.indexed" if [ ! -f "$INDEX_MARKER" ]; then echo "" echo "=== First Time Setup ===" echo "Indexing documentation into vector store..." echo "This may take a few minutes..." echo "" # Run indexing script python /app/scripts/index_docs.py # Create marker file to prevent re-indexing if [ $? -eq 0 ]; then mkdir -p "$VECTOR_STORE_PATH" touch "$INDEX_MARKER" echo "" echo "✓ Documentation indexed successfully!" else echo "" echo "⚠ Warning: Documentation indexing failed. Chat will work with limited functionality." echo " The chat service will still start but won't have access to indexed documentation." fi else echo "✓ Vector store already initialized (found marker: $INDEX_MARKER)" echo " To re-index, delete the volume: docker volume rm datacenter-docs-chat-data-dev" fi echo "" echo "=== Starting Chat Server ===" echo "Listening on port 8001..." echo "" # Start the chat server exec python -m datacenter_docs.chat.main