Spaces:
Sleeping
Sleeping
File size: 1,870 Bytes
f6278c5 385121f f6278c5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #!/bin/bash
# Chatty Application Startup Script
echo "Starting Chatty..."
# Check if virtual environment is activated
if [[ "$VIRTUAL_ENV" == "" ]]; then
echo "Activating virtual environment..."
source atlas_env/bin/activate
fi
# Determine environment
FLASK_ENV=${FLASK_ENV:-development}
echo "Environment: $FLASK_ENV"
# Check configuration based on environment
if [ "$FLASK_ENV" = "production" ]; then
echo "Production mode - validating configuration..."
python deploy.py check-prod
if [ $? -ne 0 ]; then
echo "❌ Production configuration validation failed!"
echo "Please fix configuration issues before starting in production mode."
exit 1
fi
echo "✅ Production configuration validated"
elif [ "$FLASK_ENV" = "development" ]; then
# Check if .env file exists for development
if [ ! -f .env ]; then
echo "Warning: .env file not found!"
echo "Setting up development environment..."
python deploy.py setup-dev
echo "Please edit .env file with your configuration and restart."
exit 1
fi
fi
# Test database connection
echo "Testing database connection..."
python -c "from database import test_connection; exit(0 if test_connection() else 1)"
if [ $? -ne 0 ]; then
echo "❌ Database connection failed!"
echo "Please check your MongoDB configuration in .env file."
exit 1
fi
echo "✅ Database connection successful"
# Clean up anonymous session data on startup
echo "Cleaning up anonymous session data..."
python cleanup_anonymous.py
if [ $? -eq 0 ]; then
echo "✅ Anonymous session cleanup completed"
else
echo "⚠️ Anonymous session cleanup encountered issues (continuing anyway)"
fi
# Run the application
PORT=${PORT:-7860}
echo "Starting Chatty server on http://localhost:$PORT"
echo "Press Ctrl+C to stop"
echo ""
python app.py |