legal_assistant / start.sh
ChristianRukundo's picture
FEAT: Implement automated first-time setup script
aeffbe2
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
# Define the path for a "flag" file that tells us if initialization is done
INITIALIZED_FLAG="/app/data/.initialized"
# --- First-Time Startup Logic ---
# Check if the flag file does NOT exist
if [ ! -f "$INITIALIZED_FLAG" ]; then
echo "--- FIRST-TIME STARTUP DETECTED ---"
echo "--> Running knowledge base processing (process_docs.py)..."
# Run the processing script. This will create the database and vector store.
python process_docs.py
echo "--> Knowledge base processing complete."
# Create the flag file to prevent this block from running again
touch "$INITIALIZED_FLAG"
echo "--> Initialization flag created at $INITIALIZED_FLAG"
else
echo "--- SUBSEQUENT STARTUP DETECTED ---"
echo "--> Skipping knowledge base processing."
fi
# --- Start the Main Application ---
echo "--> Starting Uvicorn server..."
# Use exec to replace the shell process with the Uvicorn process.
# This is a best practice for Docker containers.
exec uvicorn main:app --host 0.0.0.0 --port 8000