#!/bin/bash # Production startup script for Sharey with Gunicorn # Usage: ./start_production.sh set -e echo "๐Ÿš€ Starting Sharey in Production Mode with Gunicorn" echo "==================================================" # Check if we're in the right directory if [ ! -f "wsgi.py" ]; then echo "โŒ Error: wsgi.py not found. Please run this script from the Sharey root directory." exit 1 fi # Check if virtual environment exists if [ ! -d ".venv" ]; then echo "โŒ Virtual environment not found. Please run setup first." exit 1 fi # Activate virtual environment echo "๐Ÿ”Œ Activating virtual environment..." source .venv/bin/activate # Check if config exists if [ ! -f "config.json" ]; then echo "โš ๏ธ Warning: config.json not found. Creating from example..." cp config.json.example config.json echo "โœ๏ธ Please edit config.json with your settings and run again." exit 1 fi # Create logs directory mkdir -p logs # Validate configuration echo "๐Ÿ”ง Validating configuration..." python src/config_util.py validate || { echo "โŒ Configuration validation failed. Please fix your config.json" exit 1 } # Test storage backend echo "๐Ÿงช Testing storage backend..." python test_storage.py || { echo "โŒ Storage test failed. Please check your configuration." exit 1 } echo "โœ… All checks passed!" echo "" echo "๐ŸŒŸ Starting Gunicorn server..." echo "๐ŸŒ Server will be available at: http://0.0.0.0:8866" echo "๐Ÿ“ Working directory: $(pwd)" echo "๐Ÿ“Š Workers: $(python -c 'import multiprocessing; print(multiprocessing.cpu_count() * 2 + 1)')" echo "๐Ÿ“ Logs: logs/gunicorn_access.log, logs/gunicorn_error.log" echo "" echo "Press Ctrl+C to stop" echo "==================================================" # Start Gunicorn exec gunicorn --config gunicorn.conf.py wsgi:application